From e4ddf8b3abc8407ee67e172c739a254e5df8e7ee Mon Sep 17 00:00:00 2001 From: "Tj (bougyman) Vanderpoel" Date: Fri, 15 Aug 2025 13:49:09 -0500 Subject: [PATCH 1/3] fix: Ensure we exit after saying Bye Bye --- lib/leopard/nats_api_server.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/leopard/nats_api_server.rb b/lib/leopard/nats_api_server.rb index b165dd1..f38bbf5 100644 --- a/lib/leopard/nats_api_server.rb +++ b/lib/leopard/nats_api_server.rb @@ -138,7 +138,7 @@ def shutdown(workers, pool) logger.warn 'Pool is shut down, waiting for termination!' pool.wait_for_termination logger.warn 'Bye bye!' - wake_main_thread + wake_main_thread_and_exit! end end @@ -165,10 +165,12 @@ def trap_signals(workers, pool) # If the main thread is not blocked, this method does nothing. # # @return [void] - def wake_main_thread + def wake_main_thread_and_exit! Thread.main.wakeup rescue ThreadError nil + ensure + exit end end From a454f688ec542949839ebdeace8cb731048e0f1f Mon Sep 17 00:00:00 2001 From: "Tj (bougyman) Vanderpoel" Date: Fri, 15 Aug 2025 13:54:17 -0500 Subject: [PATCH 2/3] fix: Gives a more relevant error code on exit --- lib/leopard/nats_api_server.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/leopard/nats_api_server.rb b/lib/leopard/nats_api_server.rb index f38bbf5..eeeb3ab 100644 --- a/lib/leopard/nats_api_server.rb +++ b/lib/leopard/nats_api_server.rb @@ -167,10 +167,11 @@ def trap_signals(workers, pool) # @return [void] def wake_main_thread_and_exit! Thread.main.wakeup + exit 0 rescue ThreadError - nil - ensure - exit + exit 0 + rescue StandardError + exit 1 end end From 01b8d1981de26019cc840130d33b0e674bfa2b3a Mon Sep 17 00:00:00 2001 From: "Tj (bougyman) Vanderpoel" Date: Fri, 15 Aug 2025 14:11:06 -0500 Subject: [PATCH 3/3] fix: Corrects the method documentation (nod Thibs) --- lib/leopard/nats_api_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/leopard/nats_api_server.rb b/lib/leopard/nats_api_server.rb index eeeb3ab..26b8671 100644 --- a/lib/leopard/nats_api_server.rb +++ b/lib/leopard/nats_api_server.rb @@ -162,7 +162,7 @@ def trap_signals(workers, pool) # Wakes up the main thread to allow it to continue execution after the server is stopped. # This is useful when the server is running in a blocking mode. - # If the main thread is not blocked, this method does nothing. + # If the main thread is not blocked, this method does just exits. # # @return [void] def wake_main_thread_and_exit!