From 5f70585e84e0e6612f3144e8099e8e4ae071d2de Mon Sep 17 00:00:00 2001 From: Ye Lin Aung Date: Wed, 12 May 2021 15:43:44 +0630 Subject: [PATCH 1/3] Log error if worker can not be started --- lib/puma/cluster/worker.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/puma/cluster/worker.rb b/lib/puma/cluster/worker.rb index daf7c486db..f908a746a0 100644 --- a/lib/puma/cluster/worker.rb +++ b/lib/puma/cluster/worker.rb @@ -33,13 +33,13 @@ def run Signal.trap "SIGINT", "IGNORE" Signal.trap "SIGCHLD", "DEFAULT" - Thread.new do + Thread.new do Puma.set_thread_name "worker check pipe" IO.select [@check_pipe] log "! Detected parent died, dying" exit! 1 end - + # If we're not running under a Bundler context, then # report the info about the context we will be using if !ENV['BUNDLE_GEMFILE'] @@ -54,7 +54,15 @@ def run # things in shape before booting the app. @launcher.config.run_hooks :before_worker_boot, index, @launcher.events + begin server = @server ||= start_server + rescue Exception => e + log "! Unable to start worker" + log e.backtrace[0] + sleep 1 + exit 1 + end + restart_server = Queue.new << true << false fork_worker = @options[:fork_worker] && index == 0 From 3019cce8ac9f1afa7aa1e062e52fcfe4cf7a049f Mon Sep 17 00:00:00 2001 From: Ye Lin Aung Date: Wed, 12 May 2021 15:49:58 +0630 Subject: [PATCH 2/3] Removed sleeping of worker --- lib/puma/cluster/worker.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/puma/cluster/worker.rb b/lib/puma/cluster/worker.rb index f908a746a0..479752d060 100644 --- a/lib/puma/cluster/worker.rb +++ b/lib/puma/cluster/worker.rb @@ -59,7 +59,6 @@ def run rescue Exception => e log "! Unable to start worker" log e.backtrace[0] - sleep 1 exit 1 end From f893c57b919ce0004effc1bab97441fe50c517f5 Mon Sep 17 00:00:00 2001 From: Ye Lin Aung Date: Thu, 13 May 2021 03:16:27 +0630 Subject: [PATCH 3/3] Runned rubocop --- lib/puma/cluster/worker.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puma/cluster/worker.rb b/lib/puma/cluster/worker.rb index 479752d060..8060f75847 100644 --- a/lib/puma/cluster/worker.rb +++ b/lib/puma/cluster/worker.rb @@ -39,7 +39,7 @@ def run log "! Detected parent died, dying" exit! 1 end - + # If we're not running under a Bundler context, then # report the info about the context we will be using if !ENV['BUNDLE_GEMFILE'] @@ -54,9 +54,9 @@ def run # things in shape before booting the app. @launcher.config.run_hooks :before_worker_boot, index, @launcher.events - begin + begin server = @server ||= start_server - rescue Exception => e + rescue Exception => e log "! Unable to start worker" log e.backtrace[0] exit 1