Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/leopard/nats_api_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -162,13 +162,16 @@ 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
def wake_main_thread_and_exit!
Thread.main.wakeup
exit 0
rescue ThreadError
nil
exit 0
rescue StandardError
exit 1
end
end

Expand Down