Sha256: 195afbd02d88de1ffbc8dd63803bd7c555288189fecc65979dc46587941b9949

Contents?: true

Size: 928 Bytes

Versions: 16

Compression:

Stored size: 928 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 send QUIT"
  end

  if defined? ActiveRecord::Base
    config = ActiveRecord::Base.configurations[Rails.env] ||
      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

16 entries across 16 versions & 6 rubygems

Version Path
welaika-suspenders-2.0.0.pre templates/unicorn.rb
ajmalafif-jumpstart-1.18.8 templates/unicorn.rb
ajmalafif-jumpstart-1.18.7 templates/unicorn.rb
ajmalafif-jumpstart-1.18.6 templates/unicorn.rb
ajmalafif-jumpstart-1.18.5 templates/unicorn.rb
ajmalafif-jumpstart-1.18.4 templates/unicorn.rb
ajmalafif-suspenders-1.18.2 templates/unicorn.rb
ajmalafif-suspenders-1.18.1 templates/unicorn.rb
ajmalafif-suspenders-1.18.0 templates/unicorn.rb
suspenders-1.18.0 templates/unicorn.rb
railsqs-1.0.1 templates/unicorn.rb
railsqs-1.0.0 templates/unicorn.rb
suspenders-1.17.0 templates/unicorn.rb
suspenders-1.16.0 templates/unicorn.rb
shoelaces-0.1.0 templates/unicorn.rb
suspenders-1.15.0 templates/unicorn.rb