我想用 Capistrano 启动 sidekiq。下面是代码
namespace :sidekiq do
task :start do
run "cd #{current_path} && bundle exec sidekiq -c 10 -e production -L log/sidekiq.log &"
p capture("ps aux | grep sidekiq | awk '{print $2}' | sed -n 1p").strip!
end
end
它执行成功但 sidekiq 仍然没有在服务器上启动。
输出:
$ cap sidekiq:start
triggering load callbacks
* 2014-06-03 15:03:01 executing `sidekiq:start'
* executing "cd /home/project/current && bundle exec sidekiq -c 10 -e production -L log/sidekiq.log &"
servers: ["x.x.x.x"]
[x.x.x.x] executing command
command finished in 1229ms
* executing "ps aux | grep sidekiq | awk '{print $2}' | sed -n 1p"
servers: ["x.x.x.x"]
[x.x.x.x] executing command
command finished in 1229ms
"19291"
最佳答案
你的问题出在这里:
cd /home/project/current && bundle exec sidekiq -c 10 -e production -L log/sidekiq.log &
当你在结束命令中添加 &
时,命令在一个单独的进程中执行,但这个进程仍然是当前进程的子进程,并在当前进程停止时终止。相反,您需要将 sidekiq 作为守护进程运行。
bundle exec sidekiq -c 10 -e production -L log/sidekiq.log -d
注意额外的 -d
选项
关于ruby - 使用 Capistrano 启动 sidekiq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24011860/