Restart DelayedJob workers after they crash
DelayedJob offers the `--monitor` (aliased as `-m`) option to create a process that monitors the workers and restarts them when they crash. This change implies that, in order to stop the delayed job workers, we now need to pass the `-n` option when running `bin/delayed_job stop`: `RAILS_ENV=production bin/delayed_job -n 2 stop`.
This commit is contained in:
@@ -40,6 +40,7 @@ set :puma_conf, "#{release_path}/config/puma/#{fetch(:rails_env)}.rb"
|
|||||||
|
|
||||||
set :delayed_job_workers, 2
|
set :delayed_job_workers, 2
|
||||||
set :delayed_job_roles, :background
|
set :delayed_job_roles, :background
|
||||||
|
set :delayed_job_monitor, true
|
||||||
|
|
||||||
set :whenever_roles, -> { :app }
|
set :whenever_roles, -> { :app }
|
||||||
|
|
||||||
|
|||||||
@@ -42,5 +42,5 @@ end
|
|||||||
every :reboot do
|
every :reboot do
|
||||||
command "cd #{@path} && bundle exec puma -C config/puma/#{@environment}.rb"
|
command "cd #{@path} && bundle exec puma -C config/puma/#{@environment}.rb"
|
||||||
# Number of workers must be kept in sync with capistrano's delayed_job_workers
|
# Number of workers must be kept in sync with capistrano's delayed_job_workers
|
||||||
command "cd #{@path} && RAILS_ENV=#{@environment} bin/delayed_job -n 2 restart"
|
command "cd #{@path} && RAILS_ENV=#{@environment} bin/delayed_job -m -n 2 restart"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user