Sha256: 0904ffb73a817f07ce39831a187f75851dd601951fd5fb38668d099e9c72230e

Contents?: true

Size: 1.42 KB

Versions: 10

Compression:

Stored size: 1.42 KB

Contents

# config/unicorn.rb

worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
timeout Integer(ENV['WEB_TIMEOUT'] || 15)

# combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
  GC.copy_on_write_friendly = true

# Enable this flag to have unicorn test client connections by writing the
# beginning of the HTTP headers before calling the application.  This
# prevents calling the application for connections that have disconnected
# while queued.  This is only guaranteed to detect clients on the same
# host unicorn runs on, and unlikely to detect disconnects even on a
# fast LAN.
check_client_connection false

# Listen only on Heroku TCP port.
# We use a shorter backlog for quicker failover when busy.
listen ENV['PORT'], :backlog => Integer(ENV['UNICORN_BACKLOG'] || 200), :tcp_nopush => 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

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|
  GC.disable

  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pah-0.0.12 lib/pah/files/config/unicorn.rb
pah-0.0.11 lib/pah/files/config/unicorn.rb
pah-0.0.10 lib/pah/files/config/unicorn.rb
pah-0.0.9 lib/pah/files/config/unicorn.rb
pah-0.0.8 lib/pah/files/config/unicorn.rb
pah-0.0.7 lib/pah/files/config/unicorn.rb
pah-0.0.6 lib/pah/files/config/unicorn.rb
pah-0.0.5 lib/pah/files/config/unicorn.rb
pah-0.0.4 lib/pah/files/config/unicorn.rb
pah-0.0.3 lib/pah/files/config/unicorn.rb