Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

During upgrade, change directory in main process instead of workers.

This Fixes #468 by making sure the new `cwd` will be used for all the
workers spawned in the future.
  • Loading branch information...
commit 51282a7ec02ac3f214de3e002598cfae11b4f7b9 1 parent f8d49e8
@maljub01 authored
Showing with 9 additions and 13 deletions.
  1. +9 −13 lib/puma/cluster.rb
View
22 lib/puma/cluster.rb
@@ -27,6 +27,13 @@ def stop_workers
def start_phased_restart
@phase += 1
log "- Starting phased worker restart, phase: #{@phase}"
+
+ # Be sure to change the directory again before loading
+ # the app. This way we can pick up new code.
+ if dir = @options[:worker_directory]
+ log "+ Changing to #{dir}"
+ Dir.chdir dir
+ end
end
class Worker
@@ -80,14 +87,12 @@ def kill
def spawn_workers
diff = @options[:workers] - @workers.size
- upgrade = (@phased_state == :waiting)
-
master = Process.pid
diff.times do
idx = next_worker_index
- pid = fork { worker(idx, upgrade, master) }
+ pid = fork { worker(idx, master) }
@cli.debug "Spawned worker: #{pid}"
@workers << Worker.new(idx, pid, @phase)
end
@@ -162,7 +167,7 @@ def wakeup!
end
end
- def worker(index, upgrade, master)
+ def worker(index, master)
$0 = "puma: cluster worker #{index}: #{master}"
Signal.trap "SIGINT", "IGNORE"
@@ -175,15 +180,6 @@ def worker(index, upgrade, master)
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
-
# Invoke any worker boot hooks so they can get
# things in shape before booting the app.
hooks = @options[:worker_boot]
Please sign in to comment.
Something went wrong with that request. Please try again.