有什么方法可以获取在 Mina 服务器上执行的命令的结果吗?
Is there any way to get result of the command executed on server in Mina?
我正在将我的 Rails 应用程序部署从 Capistrano 移动到 Mina。唯一剩下要做的就是编写一个任务来重启服务器。我已经完成了启动服务器的部分,但我不明白如何停止它。
当我使用 Capistrano 时,我有以下任务:
desc 'Stop Unicorn'
task :stop do
on roles(:app) do
if test("[ -f #{fetch(:unicorn_pid)} ]")
execute :kill, capture(:cat, fetch(:unicorn_pid))
end
end
end
这个,据我理解,首先运行test
命令判断文件是否存在,然后在需要时运行kill命令。除了如何在服务器上执行 test
函数并获取其结果以对其执行某些操作外,我了解如何在 Mina 中完成所有这些操作。
这是我现在使用的,
task :restart_server => :environment do
queue "cd #{deploy_to}/current"
if File.exists? unicorn_pid
queue "kill `cat #{unicorn_pid}`"
end
queue "bundle exec unicorn -c #{deploy_to}/#{shared_path}/config/unicorn.rb -E production -D"
end
但这行不通,我想我明白为什么(因为 File.exists
字符串是在客户端而不是服务器端执行的)。
那么,我该怎么办?
决定从 queue
中使用 运行 test
功能会更容易,就像这样:
task :restart_server => :environment do
queue "cd #{deploy_to}/current"
queue "[ -f #{unicorn_pid} ] && kill $(cat #{unicorn_pid})"
queue "bundle exec unicorn -c #{deploy_to}/#{shared_path}/config/unicorn.rb -E production -D"
end
我正在将我的 Rails 应用程序部署从 Capistrano 移动到 Mina。唯一剩下要做的就是编写一个任务来重启服务器。我已经完成了启动服务器的部分,但我不明白如何停止它。
当我使用 Capistrano 时,我有以下任务:
desc 'Stop Unicorn'
task :stop do
on roles(:app) do
if test("[ -f #{fetch(:unicorn_pid)} ]")
execute :kill, capture(:cat, fetch(:unicorn_pid))
end
end
end
这个,据我理解,首先运行test
命令判断文件是否存在,然后在需要时运行kill命令。除了如何在服务器上执行 test
函数并获取其结果以对其执行某些操作外,我了解如何在 Mina 中完成所有这些操作。
这是我现在使用的,
task :restart_server => :environment do
queue "cd #{deploy_to}/current"
if File.exists? unicorn_pid
queue "kill `cat #{unicorn_pid}`"
end
queue "bundle exec unicorn -c #{deploy_to}/#{shared_path}/config/unicorn.rb -E production -D"
end
但这行不通,我想我明白为什么(因为 File.exists
字符串是在客户端而不是服务器端执行的)。
那么,我该怎么办?
决定从 queue
中使用 运行 test
功能会更容易,就像这样:
task :restart_server => :environment do
queue "cd #{deploy_to}/current"
queue "[ -f #{unicorn_pid} ] && kill $(cat #{unicorn_pid})"
queue "bundle exec unicorn -c #{deploy_to}/#{shared_path}/config/unicorn.rb -E production -D"
end