Last active
August 29, 2015 14:27
-
-
Save jturkel/f5e24f22fc1588b3e586 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Put this in config/delayed_job_worker_pool.rb | |
| workers Integer(ENV.fetch('NUM_WORKERS', 1)) | |
| queues ENV.fetch('QUEUES', '').split(',') | |
| sleep_delay ENV['WORKER_SLEEP_DELAY'] | |
| preload_app | |
| # This runs in the master process after preloading the app but | |
| # before starting any workers | |
| after_preload_app do | |
| puts "Master #{Process.pid} preloaded application" | |
| # Disconnect any connections that won't be inherited | |
| ActiveRecord::Base.connection_pool.disconnect! | |
| end | |
| # This runs in the worker processes after it has been forked | |
| on_worker_boot do | |
| puts "Worker #{Process.pid} started" | |
| # Re-establish any connections | |
| ActiveRecord::Base.establish_connection | |
| end | |
| # This runs in the master process after a worker starts | |
| after_worker_boot do |worker_info| | |
| puts "Master #{Process.pid} booted worker #{worker_info.process_id}" | |
| end | |
| # This runs in the master process after a worker shuts down | |
| after_worker_shutdown do |worker_info| | |
| puts "Master #{Process.pid} detected dead worker #{worker_info.process_id}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gem 'delayed_job_worker_pool' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NUM_WORKERS=4 delayed_job_worker_pool ./config/delayed_job_worker_pool.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment