1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Add ability to detect a shutting down server. Fixes #932

This commit is contained in:
Evan Phoenix 2016-07-24 13:26:14 -07:00
parent b2be09dc3d
commit 8370d2eed0

View file

@ -242,6 +242,10 @@ module Puma
@thread_pool = ThreadPool.new(@min_threads,
@max_threads,
IOBuffer) do |client, buffer|
# Advertise this server into the thread
Thread.current[ThreadLocalKey] = self
process_now = false
begin
@ -911,5 +915,15 @@ module Puma
end
end
private :fast_write
ThreadLocalKey = :puma_server
def self.current
Thread.current[ThreadLocalKey]
end
def shutting_down?
@status == :stop || @status == :restart
end
end
end