mirror of https://github.com/tidwall/tile38.git
Add graceful shutdown on SIGTERM
This commit is contained in:
parent
dbd565d361
commit
aa1060a60f
|
@ -413,6 +413,7 @@ Developer Options:
|
||||||
}
|
}
|
||||||
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
|
shutdown := make (chan bool, 1)
|
||||||
|
|
||||||
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
|
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -433,7 +434,7 @@ Developer Options:
|
||||||
case s == syscall.SIGQUIT:
|
case s == syscall.SIGQUIT:
|
||||||
os.Exit(3)
|
os.Exit(3)
|
||||||
case s == syscall.SIGTERM:
|
case s == syscall.SIGTERM:
|
||||||
os.Exit(0xf)
|
shutdown <- true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -481,6 +482,7 @@ Developer Options:
|
||||||
AppendOnly: appendOnly,
|
AppendOnly: appendOnly,
|
||||||
AppendFileName: appendFileName,
|
AppendFileName: appendFileName,
|
||||||
QueueFileName: queueFileName,
|
QueueFileName: queueFileName,
|
||||||
|
Shutdown: shutdown,
|
||||||
}
|
}
|
||||||
if err := server.Serve(opts); err != nil {
|
if err := server.Serve(opts); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Reference in New Issue