Skip to content

Commit 11a7584

Browse files
authored
fix: Ensure we exit after saying Bye Bye (#33)
* fix: Ensure we exit after saying Bye Bye * fix: Gives a more relevant error code on exit * fix: Corrects the method documentation (nod Thibs)
1 parent a86b1c9 commit 11a7584

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/leopard/nats_api_server.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def shutdown(workers, pool)
138138
logger.warn 'Pool is shut down, waiting for termination!'
139139
pool.wait_for_termination
140140
logger.warn 'Bye bye!'
141-
wake_main_thread
141+
wake_main_thread_and_exit!
142142
end
143143
end
144144

@@ -162,13 +162,16 @@ def trap_signals(workers, pool)
162162

163163
# Wakes up the main thread to allow it to continue execution after the server is stopped.
164164
# This is useful when the server is running in a blocking mode.
165-
# If the main thread is not blocked, this method does nothing.
165+
# If the main thread is not blocked, this method does just exits.
166166
#
167167
# @return [void]
168-
def wake_main_thread
168+
def wake_main_thread_and_exit!
169169
Thread.main.wakeup
170+
exit 0
170171
rescue ThreadError
171-
nil
172+
exit 0
173+
rescue StandardError
174+
exit 1
172175
end
173176
end
174177

0 commit comments

Comments
 (0)