|
|
@ -14,9 +14,13 @@ var kill = make(chan struct{}) |
|
|
// closed once all the posthooks have been called.
|
|
|
// closed once all the posthooks have been called.
|
|
|
var wait = make(chan struct{}) |
|
|
var wait = make(chan struct{}) |
|
|
|
|
|
|
|
|
|
|
|
// Whether new requests should be accepted. When false, new requests are refused.
|
|
|
|
|
|
var acceptingRequests bool = true |
|
|
|
|
|
|
|
|
// This is the WaitGroup that indicates when all the connections have gracefully
|
|
|
// This is the WaitGroup that indicates when all the connections have gracefully
|
|
|
// shut down.
|
|
|
// shut down.
|
|
|
var wg sync.WaitGroup |
|
|
var wg sync.WaitGroup |
|
|
|
|
|
var wgLock sync.Mutex |
|
|
|
|
|
|
|
|
// This lock protects the list of pre- and post- hooks below.
|
|
|
// This lock protects the list of pre- and post- hooks below.
|
|
|
var hookLock sync.Mutex |
|
|
var hookLock sync.Mutex |
|
|
@ -91,6 +95,11 @@ func PostHook(f func()) { |
|
|
func waitForSignal() { |
|
|
func waitForSignal() { |
|
|
<-sigchan |
|
|
<-sigchan |
|
|
|
|
|
|
|
|
|
|
|
// Prevent servicing of any new requests.
|
|
|
|
|
|
wgLock.Lock() |
|
|
|
|
|
acceptingRequests = false |
|
|
|
|
|
wgLock.Unlock() |
|
|
|
|
|
|
|
|
hookLock.Lock() |
|
|
hookLock.Lock() |
|
|
defer hookLock.Unlock() |
|
|
defer hookLock.Unlock() |
|
|
|
|
|
|
|
|
|