Merge pull request #2660 from nspcc-dev/handle-sigterm
cli/server: handle SIGTERM gracefully
This commit is contained in:
commit
e31c3b5246
1 changed files with 2 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||||
|
@ -119,6 +120,7 @@ func newGraceContext() context.Context {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
stop := make(chan os.Signal, 1)
|
stop := make(chan os.Signal, 1)
|
||||||
signal.Notify(stop, os.Interrupt)
|
signal.Notify(stop, os.Interrupt)
|
||||||
|
signal.Notify(stop, syscall.SIGTERM)
|
||||||
go func() {
|
go func() {
|
||||||
<-stop
|
<-stop
|
||||||
cancel()
|
cancel()
|
||||||
|
|
Loading…
Reference in a new issue