Sha256: a4b71fe79b9f91c1c4cf8419d149a02efc52874023ebca9e352427c01b8e2135
Contents?: true
Size: 1.84 KB
Versions: 5
Compression:
Stored size: 1.84 KB
Contents
rails_env = ENV['RAILS_ENV'] || 'production' deploy_to = '<%= deploy_to %>' rails_root = "#{deploy_to}/current" tmp_dir = "#{deploy_to}/shared/tmp" pid_dir = "#{tmp_dir}/pids" if File.directory?(tmp_dir) && !File.directory?(pid_dir) puts "creating pid dir #{pid_dir}" Dir.mkdir(pid_dir) end pid_file = "#{pid_dir}/unicorn.pid" log_file = "#{deploy_to}/shared/log/unicorn.log" err_log_file = "#{deploy_to}/shared/log/unicorn.error.log" old_pid_file = pid_file + '.oldbin' worker_processes 1 working_directory rails_root timeout 120 # Specify path to socket unicorn listens to, # we will use this in our nginx.conf later listen "127.0.0.1:<%= port %>" pid pid_file # Set log file paths stderr_path err_log_file stdout_path log_file # http://tech.tulentsev.com/2012/03/deploying-with-sinatra-capistrano-unicorn/ # NOTE: http://unicorn.bogomips.org/SIGNALS.html preload_app true # make sure that Bundler finds the Gemfile before_exec do |server| ENV['BUNDLE_GEMFILE'] = File.join( rails_root, 'Gemfile' ) end before_fork do |server, worker| # при использовании preload_app = true здесь должно быть закрытие всех открытых сокетов # Mongoid сам заботится о переконнекте # http://two.mongoid.org/docs/upgrading.html # http://stackoverflow.com/a/9498372/2041969 # убиваем параллельный старый-процесс просле старта нового if File.exists?( old_pid_file ) begin Process.kill( "QUIT", File.read( old_pid_file ).to_i ) rescue Errno::ENOENT, Errno::ESRCH puts "Old master alerady dead" end end end after_fork do |server, worker| # pid-ы дочерних процессов child_pid_file = server.config[:pid].sub(".pid", ".#{worker.nr}.pid" system("echo #{Process.pid} > #{child_pid_file}") end
Version data entries
5 entries across 5 versions & 1 rubygems