[英]Background task with Capistrano
I know this question has been asked a lot, but I cannot manage to get it right. 我知道这个问题已经问了很多,但是我无法设法解决。 I have already looked at : 我已经看过了:
I am using capistrano to deploy a server in scala. 我正在使用capistrano在scala中部署服务器。 My task looks like this : 我的任务看起来像这样:
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 is an sbt plugin that creates a script in target/start. start-script是一个sbt插件,可在target / start中创建一个脚本。 When I run the task, the output is : 当我运行任务时,输出为:
* 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
but my server is not started... When omitting the "&" at the end of the command, the server is started but the capistrano script is blocked. 但是我的服务器未启动...在命令末尾省略“&”时,服务器已启动,但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
Thanks in advance for your answers. 预先感谢您的回答。
我找到了解决方案,只需添加pty:最后是false
run "cd #{deploy_to} && export PORT=#{server_port} && export ENV=#{env} && nohup target/start > /dev/null 2>&1 &" pty: false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.