Sha256: 16bf68fae2dd69e217bab2070676a42443e6da05788b01163173b3427a805b7d

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

ENV['RAILS_ENV'] = 'production'
worker_processes 4

listen "<%="#{fetch(:app_server_host)}:#{fetch(:app_server_port)}"%>", :backlog => 2048

timeout 60

working_directory "<%=current_path%>"

pid "<%="#{shared_path}/pids/unicorn.pid"%>"
stderr_path "<%="#{shared_path}/log/unicorn.stderr.log"%>"
stdout_path "<%="#{shared_path}/log/unicorn.stdout.log"%>"

preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
  GC.copy_on_write_friendly = true

before_fork do |server, worker|
  # Close connections on the master process if ActiveRecord is loaded
  if defined?(ActiveRecord::Base)
    ActiveRecord::Base.connection.disconnect!
  end

  old_pid = "#{server.config[:pid]}.oldbin"

  if File.exists?(old_pid) && server.pid != old_pid
    begin
      sig = (worker.nr + 1) >= server.worker_processes ? :TERM : :TTOU
      Process.kill(sig, File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
      # It’s already gone
    end
  end
end

after_fork do |server, worker|
  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
capistrano-unformatt-1.0 vendor/templates/unicorn.rb.erb
capistrano-unformatt-0.7 vendor/templates/unicorn.rb.erb
capistrano-unformatt-0.6 vendor/templates/unicorn.rb.erb
capistrano-unformatt-0.5 vendor/templates/unicorn.rb.erb
capistrano-unformatt-0.4 vendor/templates/unicorn.rb.erb
capistrano-unformatt-0.3 vendor/templates/unicorn.rb.erb
capistrano-unformatt-0.2 vendor/templates/unicorn.rb.erb
capistrano-unformatt-0.1 vendor/templates/unicorn.rb.erb