Sha256: f333c0d2a95c60d5c3f4307876341d4a51c9512e33760666f484381c9155dfb6

Contents?: true

Size: 878 Bytes

Versions: 3

Compression:

Stored size: 878 Bytes

Contents

worker_processes (ENV["UNICORN_WORKERS"] || 3).to_i
timeout (ENV["UNICORN_TIMEOUT"] || 15).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

3 entries across 3 versions & 1 rubygems

Version Path
roboparts-0.5.4 templates/unicorn.rb
roboparts-0.5.3 templates/unicorn.rb
roboparts-0.5.2 templates/unicorn.rb