Sha256: 505ee2df23bde2015af32a76bffe651b43e0f66e8d614b73a163d5b6bdc25813

Contents?: true

Size: 1.14 KB

Versions: 20

Compression:

Stored size: 1.14 KB

Contents

ENV['RAILS_ENV'] = '<%= fetch(:rails_env, 'production') %>'
worker_processes <%= fetch(:app_server_workers, 4) %>

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

timeout <%= fetch(:app_server_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

20 entries across 20 versions & 1 rubygems

Version Path
capistrano-unformatt-2.4 vendor/templates/unicorn.rb.erb
capistrano-unformatt-2.3 vendor/templates/unicorn.rb.erb
capistrano-unformatt-2.2 vendor/templates/unicorn.rb.erb
capistrano-unformatt-2.1 vendor/templates/unicorn.rb.erb
capistrano-unformatt-2.0 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.16 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.15 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.14.1 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.14 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.13 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.12 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.11 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.10 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.9 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.8 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.7 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.6 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.5 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.4 vendor/templates/unicorn.rb.erb
capistrano-unformatt-1.3 vendor/templates/unicorn.rb.erb