1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/lib/sidekiq/capistrano.rb

33 lines
993 B
Ruby
Raw Normal View History

2012-02-26 23:36:30 -05:00
Capistrano::Configuration.instance.load do
before "deploy", "sidekiq:quiet"
2012-02-26 23:36:30 -05:00
after "deploy", "sidekiq:restart"
_cset(:sidekiq_timeout) { 5 }
2012-02-26 23:36:30 -05:00
namespace :sidekiq do
desc "Quiet sidekiq (stop accepting new work)"
task :quiet do
run "cd #{current_path} && kill -USR1 `cat #{current_path}/tmp/pids/sidekiq.pid`"
2012-02-26 23:36:30 -05:00
end
desc "Stop sidekiq"
task :stop do
2012-03-09 22:01:19 -05:00
run "cd #{current_path} && kill `cat #{current_path}/tmp/pids/sidekiq.pid` && sleep #{fetch :sidekiq_timeout} && kill -9 `cat #{current_path}/tmp/pids/sidekiq.pid` ; rm #{current_path}/tmp/pids/sidekiq.pid"
2012-02-26 23:36:30 -05:00
end
desc "Start sidekiq"
task :start do
rails_env = fetch(:rails_env, "production")
run "cd #{current_path} && nohup bundle exec sidekiq -e #{rails_env} -C #{current_path}/config/sidekiq.yml -P #{current_path}/tmp/pids/sidekiq.pid >> #{current_path}/log/sidekiq.log 2>&1 &"
2012-02-26 23:36:30 -05:00
end
desc "Restart sidekiq"
task :restart do
stop
start
end
end
end