【发布时间】:2013-08-07 05:54:14
【问题描述】:
我知道这个问题被问了很多,但我无法正确回答。我已经看过了:
- Starting background tasks with Capistrano
- launching background process in capistrano task
- http://whowish-programming.blogspot.fr/2011/04/run-background-process-with-capistrano.html
我正在使用 capistrano 在 scala 中部署服务器。我的任务是这样的:
desc "Start server"
task :start do
run "cd #{deploy_to} && ./sbt compile start-script"
run "cd #{deploy_to} && export PORT=#{server_port} && export ENV=#{env} && nohup target/start > /dev/null 2>&1 &"
end
start-script 是一个在 target/start 中创建脚本的 sbt 插件。 当我运行任务时,输出是:
* executing "cd /home/ubuntu/* && export PORT=* && export ENV=integration && nohup target/start > /dev/null 2>&1 &"
servers: ["54.217.224.197"]
[54.217.224.197] executing command
command finished in 1015ms
但是我的服务器没有启动...当省略命令末尾的“&”时,服务器启动但 capistrano 脚本被阻止。
* executing "cd /home/ubuntu/* && export PORT=* && export ENV=integration && nohup target/start > /dev/null 2>&1"
servers: ["54.217.224.197"]
[54.217.224.197] executing command
提前感谢您的回答。
【问题讨论】:
标签: ruby-on-rails background capistrano sbt nohup