mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +00:00
cli/server: handle SIGTERM gracefully
That's the expected and desired behavior, SIGKILL is always there to do bad things.
This commit is contained in:
parent
bf06b32278
commit
1850c04d65
1 changed files with 2 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||
|
@ -119,6 +120,7 @@ func newGraceContext() context.Context {
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt)
|
||||
signal.Notify(stop, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-stop
|
||||
cancel()
|
||||
|
|
Loading…
Reference in a new issue