mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Change directory in working during upgrade. Fixes #185
This commit is contained in:
parent
f336e8f133
commit
40af41e5ef
1 changed files with 15 additions and 2 deletions
|
@ -63,6 +63,7 @@ module Puma
|
||||||
|
|
||||||
if s_env.ino == s_pwd.ino and s_env.dev == s_pwd.dev
|
if s_env.ino == s_pwd.ino and s_env.dev == s_pwd.dev
|
||||||
@restart_dir = dir
|
@restart_dir = dir
|
||||||
|
@options[:worker_directory] = dir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -208,6 +209,7 @@ module Puma
|
||||||
|
|
||||||
o.on "--dir DIR", "Change to DIR before starting" do |d|
|
o.on "--dir DIR", "Change to DIR before starting" do |d|
|
||||||
@options[:directory] = d.to_s
|
@options[:directory] = d.to_s
|
||||||
|
@options[:worker_directory] = d.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
o.on "-e", "--environment ENVIRONMENT",
|
o.on "-e", "--environment ENVIRONMENT",
|
||||||
|
@ -481,7 +483,7 @@ module Puma
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def worker
|
def worker(upgrade)
|
||||||
$0 = "puma: cluster worker: #{@master_pid}"
|
$0 = "puma: cluster worker: #{@master_pid}"
|
||||||
Signal.trap "SIGINT", "IGNORE"
|
Signal.trap "SIGINT", "IGNORE"
|
||||||
|
|
||||||
|
@ -494,6 +496,15 @@ module Puma
|
||||||
exit! 1
|
exit! 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Be sure to change the directory again before loading
|
||||||
|
# the app. This way we can pick up new code.
|
||||||
|
if upgrade
|
||||||
|
if dir = @options[:worker_directory]
|
||||||
|
log "+ Changing to #{dir}"
|
||||||
|
Dir.chdir dir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
min_t = @options[:min_threads]
|
min_t = @options[:min_threads]
|
||||||
max_t = @options[:max_threads]
|
max_t = @options[:max_threads]
|
||||||
|
|
||||||
|
@ -560,8 +571,10 @@ module Puma
|
||||||
def spawn_workers
|
def spawn_workers
|
||||||
diff = @options[:workers] - @workers.size
|
diff = @options[:workers] - @workers.size
|
||||||
|
|
||||||
|
upgrade = (@phased_state == :waiting)
|
||||||
|
|
||||||
diff.times do
|
diff.times do
|
||||||
pid = fork { worker }
|
pid = fork { worker(upgrade) }
|
||||||
debug "Spawned worker: #{pid}"
|
debug "Spawned worker: #{pid}"
|
||||||
@workers << Worker.new(pid, @phase)
|
@workers << Worker.new(pid, @phase)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue