Skip to content

Instantly share code, notes, and snippets.

@MIsabelZM
Created February 18, 2015 15:15
Show Gist options
  • Save MIsabelZM/2f8a52d77bebcde3e429 to your computer and use it in GitHub Desktop.
Save MIsabelZM/2f8a52d77bebcde3e429 to your computer and use it in GitHub Desktop.
unicorn_heroku.rb
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