Created
February 9, 2012 08:39
-
-
Save douhashi/1778514 to your computer and use it in GitHub Desktop.
redmine unicorn conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$unicorn_user = "app" | |
$unicorn_group = "app" | |
worker_processes 2 | |
working_directory '/var/rails/redmine' | |
listen "127.0.0.1:3100", :tcp_nopush => true | |
listen '/tmp/.unicorn_redmine.sock' | |
timeout 30 | |
pid "tmp/pids/unicorn.pid" | |
stderr_path "log/unicorn.log" | |
stdout_path "log/unicorn.log" | |
preload_app true | |
before_fork do |server, worker| | |
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! | |
end | |
after_fork do |server, worker| | |
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection | |
begin | |
uid, gid = Process.euid, Process.egid | |
user, group = $unicorn_user, $unicorn_group | |
target_uid = Etc.getpwnam(user).uid | |
target_gid = Etc.getgrnam(group).gid | |
worker.tmp.chown(target_uid, target_gid) | |
if uid != target_uid or gid != target_gid | |
Process.initgroups(user, target_gid) | |
Process::GID.change_privilege(target_gid) | |
Process::UID.change_privilege(target_uid) | |
end | |
rescue | |
if RAILS_ENV = "development" | |
STDERR.puts "could not change user, oh well" | |
else | |
raise e | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment