2012-02-26 23:36:30 -05:00
|
|
|
Capistrano::Configuration.instance.load do
|
2012-04-16 21:56:41 -04:00
|
|
|
before "deploy", "sidekiq:quiet"
|
|
|
|
after "deploy:stop", "sidekiq:stop"
|
|
|
|
after "deploy:start", "sidekiq:start"
|
|
|
|
after "deploy:restart", "sidekiq:restart"
|
2012-02-26 23:36:30 -05:00
|
|
|
|
2012-03-27 23:19:24 -04:00
|
|
|
_cset(:sidekiq_timeout) { 10 }
|
2012-04-05 23:18:11 -04:00
|
|
|
_cset(:sidekiq_role) { :app }
|
2012-03-08 23:58:51 -05:00
|
|
|
|
2012-02-26 23:36:30 -05:00
|
|
|
namespace :sidekiq do
|
|
|
|
|
2012-03-08 23:58:51 -05:00
|
|
|
desc "Quiet sidekiq (stop accepting new work)"
|
2012-04-20 13:12:21 -04:00
|
|
|
task :quiet, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
2012-06-19 20:20:57 -04:00
|
|
|
run "if [ -d #{current_path} ] && [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then cd #{current_path} && #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid ; fi"
|
2012-02-26 23:36:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Stop sidekiq"
|
2012-04-20 13:12:21 -04:00
|
|
|
task :stop, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
2012-06-19 20:20:57 -04:00
|
|
|
run "if [ -d #{current_path} ] && [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then cd #{current_path} && #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid #{fetch :sidekiq_timeout} ; fi"
|
2012-02-26 23:36:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Start sidekiq"
|
2012-04-20 13:12:21 -04:00
|
|
|
task :start, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
2012-02-26 23:36:30 -05:00
|
|
|
rails_env = fetch(:rails_env, "production")
|
2012-04-19 17:13:23 -04:00
|
|
|
run "cd #{current_path} ; nohup #{fetch(:bundle_cmd, "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 &", :pty => false
|
2012-02-26 23:36:30 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Restart sidekiq"
|
2012-04-20 13:12:21 -04:00
|
|
|
task :restart, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
2012-02-26 23:36:30 -05:00
|
|
|
stop
|
|
|
|
start
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|