Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting sidekiq with capistrano

I want to start sidekiq with capistrano. Below is code for that

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

It executes successfully but still sidekiq is not started on server.

output:

$ 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"
like image 791
sagar junnarkar Avatar asked Jun 03 '14 09:06

sagar junnarkar


1 Answers

Your problem lies here:

  cd /home/project/current && bundle exec sidekiq -c 10 -e production -L log/sidekiq.log &

When you add & at the end command is being executed in a separate process, but this process is still a child of a current process and is terminated when current process stops. Instead you need to run sidekiq as a deamon.

bundle exec sidekiq -c 10 -e production -L log/sidekiq.log -d

Note the extra -d option

like image 66
BroiSatse Avatar answered Oct 20 '22 23:10

BroiSatse