Sha256: 80b3db49d6319c22a0fc612ab6b13c424771899c81cd24d2dd530b9ad0447821
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
rails_root = '<%= "#{deploy_to}/current" %>' rails_env = '<%= environment %>' pid_file = '<%= unicorn_pid %>' socket_file= '<%= unicorn_socket %>' log_file = '<%= deploy_to %>/current/log/unicorn.log' username = '<%= unicorn_user %>' group = '<%= unicorn_group %>' old_pid = pid_file + '.oldbin' working_directory rails_root timeout <%= unicorn_workers_timeout %> worker_processes <%= unicorn_workers %> # Listen on a Unix data socket listen socket_file, :backlog => 1024 pid pid_file stderr_path log_file stdout_path log_file preload_app true GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=) before_fork do |server, worker| if File.exists?(old_pid) && server.pid != old_pid pid = File.read(old_pid).to_i begin puts ">> Killing old unicorn process" Process.kill("QUIT", pid) rescue Errno::ECHILD, Errno::ESRCH => e $stderr.puts ">> Process #{pid} has stopped" rescue Errno::ENOENT => e $stderr.puts ">> Error killing previous instance. #{e.message}" # someone else did our job for us end end end after_fork do |server, worker| begin uid, gid = Process.euid, Process.egid target_uid = File.stat(Rails.root).uid user = Etc.getpwuid(target_uid).name target_gid = File.stat(Rails.root).gid group = Etc.getgrgid(target_gid).name worker.tmp.chown(target_uid, target_gid) if uid != target_uid || gid != target_gid Process.initgroups(user, target_gid) Process::GID.change_privilege(target_gid) Process::UID.change_privilege(target_uid) end rescue => e STDERR.puts "cannot change privileges on #{Rails.env} environment" STDERR.puts " #{e}" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ricodigo-capistrano-recipes-0.1.8 | generators/unicorn.rb.erb |
ricodigo-capistrano-recipes-0.1.7 | generators/unicorn.rb.erb |
ricodigo-capistrano-recipes-0.1.6 | generators/unicorn.rb.erb |