Created
February 18, 2015 15:15
-
-
Save MIsabelZM/2f8a52d77bebcde3e429 to your computer and use it in GitHub Desktop.
unicorn_heroku.rb
This file contains 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
run_sidekiq_in_this_thread = %w(staging).include?(ENV['RAILS_ENV']) | |
worker_processes (run_sidekiq_in_this_thread ? 2 : 3) | |
@sidekiq_pid = nil | |
before_fork do |server, worker| | |
if run_sidekiq_in_this_thread | |
@resque_pid ||= spawn("bundle exec sidekiq -c 2") | |
Rails.logger.info('Spawned sidekiq #{@request_pid}') | |
end | |
Signal.trap 'TERM' do | |
puts 'Unicorn master intercepting TERM and sending myself QUIT instead' | |
Process.kill 'QUIT', Process.pid | |
end | |
end | |
after_fork do |server, worker| | |
Signal.trap 'TERM' do | |
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment