1
0

unicorn.rb.example 837 B

1234567891011121314151617181920212223242526272829303132333435
  1. wd = File.expand_path(File.join(File.dirname(__FILE__), '..'))
  2. app_path = wd
  3. worker_processes Integer(ENV["WEB_CONCURRENCY"] || 2)
  4. preload_app true
  5. timeout 180
  6. listen "#{wd}/tmp/sockets/unicorn.socket"
  7. working_directory app_path
  8. rails_env = ENV['RAILS_ENV'] || 'production'
  9. # Log everything to one file
  10. stderr_path "log/unicorn.log"
  11. stdout_path "log/unicorn.log"
  12. # Set master PID location
  13. pid "#{wd}/tmp/pids/unicorn.pid"
  14. before_fork do |server, worker|
  15. ActiveRecord::Base.connection.disconnect!
  16. old_pid = "#{server.config[:pid]}.oldbin"
  17. if File.exist?(old_pid) && server.pid != old_pid
  18. begin
  19. Process.kill("QUIT", File.read(old_pid).to_i)
  20. rescue Errno::ENOENT, Errno::ESRCH
  21. # someone else did our job for us
  22. end
  23. end
  24. end
  25. after_fork do |server, worker|
  26. ActiveRecord::Base.establish_connection
  27. end