|
|
@ -20,6 +20,7 @@ import ( |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"os/exec" |
|
|
|
"os/exec" |
|
|
|
"syscall" |
|
|
|
"syscall" |
|
|
|
|
|
|
|
"time" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Type of service signals currently supported.
|
|
|
|
// Type of service signals currently supported.
|
|
|
@ -79,7 +80,6 @@ func (m *ServerMux) handleServiceSignals() error { |
|
|
|
// We are usually done here, close global service done channel.
|
|
|
|
// We are usually done here, close global service done channel.
|
|
|
|
globalServiceDoneCh <- struct{}{} |
|
|
|
globalServiceDoneCh <- struct{}{} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Wait for SIGTERM in a go-routine.
|
|
|
|
// Wait for SIGTERM in a go-routine.
|
|
|
|
trapCh := signalTrap(os.Interrupt, syscall.SIGTERM) |
|
|
|
trapCh := signalTrap(os.Interrupt, syscall.SIGTERM) |
|
|
|
go func(trapCh <-chan bool) { |
|
|
|
go func(trapCh <-chan bool) { |
|
|
@ -102,7 +102,11 @@ func (m *ServerMux) handleServiceSignals() error { |
|
|
|
} |
|
|
|
} |
|
|
|
runExitFn(nil) |
|
|
|
runExitFn(nil) |
|
|
|
case serviceStop: |
|
|
|
case serviceStop: |
|
|
|
log.Println("Gracefully stopping... (press Ctrl+C again to force)") |
|
|
|
log.Println("Received signal to exit.") |
|
|
|
|
|
|
|
go func() { |
|
|
|
|
|
|
|
time.Sleep(serverShutdownPoll + time.Millisecond*100) |
|
|
|
|
|
|
|
log.Println("Waiting for active connections to terminate - press Ctrl+C to quit immediately.") |
|
|
|
|
|
|
|
}() |
|
|
|
if err := m.Close(); err != nil { |
|
|
|
if err := m.Close(); err != nil { |
|
|
|
errorIf(err, "Unable to close server gracefully") |
|
|
|
errorIf(err, "Unable to close server gracefully") |
|
|
|
} |
|
|
|
} |
|
|
|