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

set default cap hooks in a pre-deploy task

Issue: sidekiq default hooks are never added for cap3

Cause:
The cap3 sidekiq hooks are added based on a cap setting, the final value of which won't be available until "before deploy." Currently the check is done when the task file is loaded.

Solution:
Check and possibly add the hooks in a pre-deploy task rather than at the top level of the task file.
This commit is contained in:
Daniel Leavitt 2013-11-16 12:32:41 -08:00
parent 570cf2d0ea
commit 4d9b4f8e8e

View file

@ -23,6 +23,12 @@ namespace :load do
end
end
namespace :deploy do
before :starting, :check_sidekiq_hooks do
invoke 'sidekiq:add_default_hooks' if fetch(:sidekiq_default_hooks)
end
end
namespace :sidekiq do
def for_each_process(&block)
fetch(:sidekiq_processes).times do |idx|
@ -30,6 +36,13 @@ namespace :sidekiq do
end
end
task :add_default_hooks do
after 'deploy:starting', 'sidekiq:quiet'
after 'deploy:updated', 'sidekiq:stop'
after 'deploy:reverted', 'sidekiq:stop'
after 'deploy:published', 'sidekiq:start'
end
desc "Quiet sidekiq (stop accepting new work)"
task :quiet do
on roles fetch(:sidekiq_role) do
@ -86,11 +99,4 @@ namespace :sidekiq do
invoke 'sidekiq:start'
end
if fetch(:sidekiq_default_hooks)
after 'deploy:starting', 'sidekiq:quiet'
after 'deploy:updated', 'sidekiq:stop'
after 'deploy:reverted', 'sidekiq:stop'
after 'deploy:published', 'sidekiq:start'
end
end