From b9500f37a27c2be502cec943978790109f9ae80a Mon Sep 17 00:00:00 2001 From: Shayon Mukherjee Date: Wed, 11 Oct 2017 08:10:13 -0700 Subject: [PATCH] Appropriately wait for worker child process when shutting down via SIGTERM This way when a SIGTERM is issued to a puma cluster (master process) the shutting down of workers/child processes successfully completes. Before this, it meant the master process will wait for every child process, not just puma specific child process. Which meant even though the workers were to successfully terminate, the server never exits as intended. --- lib/puma/cluster.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puma/cluster.rb b/lib/puma/cluster.rb index 9976103eba..ffdc3c9433 100644 --- a/lib/puma/cluster.rb +++ b/lib/puma/cluster.rb @@ -24,7 +24,9 @@ def stop_workers @workers.each { |x| x.term } begin - Process.waitall + @workers.each do |w| + Process.waitpid(w.pid) + end rescue Interrupt log "! Cancelled waiting for workers" end