Sha256: 93730b549dcc0b5566efe77d6313fece0ae52884772992fc08f3452887e359c8

Contents?: true

Size: 874 Bytes

Versions: 23

Compression:

Stored size: 874 Bytes

Contents

# https://devcenter.heroku.com/articles/rails-unicorn

worker_processes (ENV['WEB_CONCURRENCY'] || 3).to_i
timeout (ENV['WEB_TIMEOUT'] || 5).to_i
preload_app true

before_fork do |server, worker|
  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  if defined? ActiveRecord::Base
    ActiveRecord::Base.connection.disconnect!
  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

  if defined? ActiveRecord::Base
    config = Rails.application.config.database_configuration[Rails.env]
    config['reaping_frequency'] = (ENV['DB_REAPING_FREQUENCY'] || 10).to_i
    config['pool'] = (ENV['DB_POOL'] || 2).to_i
    ActiveRecord::Base.establish_connection(config)
  end
end

Version data entries

23 entries across 23 versions & 4 rubygems

Version Path
mj-suspenders-0.0.9 templates/unicorn.rb
mj-suspenders-0.0.8 templates/unicorn.rb
mj-suspenders-0.0.7 templates/unicorn.rb
mj-suspenders-0.0.6 templates/unicorn.rb
mj-suspenders-0.0.5 templates/unicorn.rb
mj-suspenders-0.0.4 templates/unicorn.rb
mj-suspenders-0.0.3 templates/unicorn.rb
mj-suspenders-0.0.2 templates/unicorn.rb
mj-suspenders-0.0.1 templates/unicorn.rb
suspenders-1.9.1 templates/unicorn.rb
suspenders-1.9.0 templates/unicorn.rb
os_suspenders-1.8.5 templates/unicorn.rb
os_suspenders-1.8.4 templates/unicorn.rb
os_suspenders-1.8.3 templates/unicorn.rb
os_suspenders-1.8.2 templates/unicorn.rb
os_suspenders-0.0.1 templates/unicorn.rb
suspenders-1.8.1 templates/unicorn.rb
suspenders-1.8.0 templates/unicorn.rb
re-rails-0.1.6 templates/unicorn.rb
re-rails-0.1.3 templates/unicorn.rb