# -*- coding: utf-8 -*- # Unicorn Configuration File for Redmine # http://unicorn.bogomips.org/examples/unicorn.conf.rb $unicorn_user = "redmine" $unicorn_group = "redmine" @dir = "/some/where/redmine" working_directory @dir worker_processes 2 listen "/var/run/unicorn.sock", :backlog => 32 timeout 30 pid "/var/run/unicorn.pid" stdout_path File.expand_path("log/unicorn.stdout.log", @dir) stderr_path File.expand_path("log/unicorn.stderr.log", @dir) preload_app true check_client_connection false GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true before_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! old_pid = "#{server.config[:pid]}.oldbin" if old_pid != server.pid begin sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU Process.kill(sig, File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH end end end after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection begin worker.user($unicorn_user,$unicorn_group) rescue => ex STDERR.puts "could not change user, oh well" STDERR.puts ex.to_s raise ex end end