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
|
||||
@restart_dir = dir
|
||||
@options[:worker_directory] = dir
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -208,6 +209,7 @@ module Puma
|
|||
|
||||
o.on "--dir DIR", "Change to DIR before starting" do |d|
|
||||
@options[:directory] = d.to_s
|
||||
@options[:worker_directory] = d.to_s
|
||||
end
|
||||
|
||||
o.on "-e", "--environment ENVIRONMENT",
|
||||
|
@ -481,7 +483,7 @@ module Puma
|
|||
end
|
||||
end
|
||||
|
||||
def worker
|
||||
def worker(upgrade)
|
||||
$0 = "puma: cluster worker: #{@master_pid}"
|
||||
Signal.trap "SIGINT", "IGNORE"
|
||||
|
||||
|
@ -494,6 +496,15 @@ module Puma
|
|||
exit! 1
|
||||
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]
|
||||
max_t = @options[:max_threads]
|
||||
|
||||
|
@ -560,8 +571,10 @@ module Puma
|
|||
def spawn_workers
|
||||
diff = @options[:workers] - @workers.size
|
||||
|
||||
upgrade = (@phased_state == :waiting)
|
||||
|
||||
diff.times do
|
||||
pid = fork { worker }
|
||||
pid = fork { worker(upgrade) }
|
||||
debug "Spawned worker: #{pid}"
|
||||
@workers << Worker.new(pid, @phase)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue