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:
parent
b2be09dc3d
commit
8370d2eed0
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue