Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

3 participants

@maljub01

This Fixes #468 by making sure the new cwd will be used for all the
workers spawned in the future.

@maljub01 maljub01 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.
51282a7
@rubencaro

+1 for this!

Also if puma could know if a phased-restart went ok, then it could only update this directory when restart goes ok.

@maljub01 maljub01 closed this
@pencilcheck

This doesn't work for me somehow using mina

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 17, 2014
  1. @maljub01

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

    maljub01 authored
    This Fixes #468 by making sure the new `cwd` will be used for all the
    workers spawned in the future.
This page is out of date. Refresh to see the latest.
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]
Something went wrong with that request. Please try again.