|
|
@ -20,7 +20,7 @@ func init() {
|
|
|
|
|
|
|
|
|
|
|
|
// https://golang.org/pkg/os/signal/#Notify
|
|
|
|
// https://golang.org/pkg/os/signal/#Notify
|
|
|
|
signals := make(chan os.Signal, 1)
|
|
|
|
signals := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(signals, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGTERM)
|
|
|
|
signal.Notify(signals, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGTERM, syscall.SIGINT)
|
|
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
v := <-signals
|
|
|
|
v := <-signals
|
|
|
@ -34,14 +34,13 @@ func init() {
|
|
|
|
profiler.Stop()
|
|
|
|
profiler.Stop()
|
|
|
|
profiler = nil
|
|
|
|
profiler = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case syscall.SIGTERM:
|
|
|
|
case syscall.SIGTERM, syscall.SIGINT:
|
|
|
|
select {
|
|
|
|
select {
|
|
|
|
case <-done:
|
|
|
|
case <-done:
|
|
|
|
// already closed
|
|
|
|
// already closed
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
close(done)
|
|
|
|
close(done)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gracefulStop(signals)
|
|
|
|
gracefulStop(signals)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
logx.Error("Got unregistered signal:", v)
|
|
|
|
logx.Error("Got unregistered signal:", v)
|
|
|
|