【问题标题】:Background task with CapistranoCapistrano 的后台任务
【发布时间】:2013-08-07 05:54:14
【问题描述】:

我知道这个问题被问了很多,但我无法正确回答。我已经看过了:

我正在使用 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


    【解决方案1】:

    我找到了解决办法,在最后加上 pty: false 就行了

    run "cd #{deploy_to} && export PORT=#{server_port} && export ENV=#{env} && nohup target/start > /dev/null 2>&1 &" pty: false
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-29
      • 2011-09-15
      • 2013-02-04
      相关资源
      最近更新 更多