Commit 00db718c by Tan Phat Nguyen

deploy unicorn

parent 1088c0c3
# paths app_path = '/web/training/phatnt'
app_path = "/web/training/phatnt/"
working_directory "#{app_path}/current" working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid" pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen # listen
listen "/tmp/unicorn-www.example.com.socket", :backlog => 64 listen "/tmp/unicorn.venshop.sock"
# logging # logging
stderr_path "log/unicorn.stderr.log" stderr_path "#{app_path}/shared/log/unicorn.stderr.log"
stdout_path "log/unicorn.stdout.log" stdout_path "#{app_path}/shared/log/unicorn.stdout.log"
# workers #workers
worker_processes 3 worker_processes 1
# use correct Gemfile on restarts # user correct Gemfile on restarts
before_exec do |server| before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "#{app_path}/current/Gemfile" ENV['BUNDLE_GEMFILE'] = "#{app_path}/current/Gemfile"
end end
...@@ -22,20 +21,19 @@ end ...@@ -22,20 +21,19 @@ end
preload_app true preload_app true
before_fork do |server, worker| before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
if defined?(ActiveRecord::Base) if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect! ActiveRecord::Base.connection.disconnect!
end end
# Before forking, kill the master process that belongs to the .oldbin PID. # Before fork, kill the master process that belongs to the .oldbin PID
# This enables 0 downtime deploys. # This enables 0 downtime deploys
old_pid = "#{server.config[:pid]}.oldbin" old_pid = "#{server.config[:pid]}.oldbin"
if File.exists?(old_pid) && server.pid != old_pid if File.exists?(old_pid) && server.pid != old_pid
begin begin
Process.kill("QUIT", File.read(old_pid).to_i) Process.kill('QUIT', File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment