Merge pull request #2660 from nspcc-dev/handle-sigterm

cli/server: handle SIGTERM gracefully
This commit is contained in:
Roman Khimov 2022-08-24 11:57:56 +03:00 committed by GitHub
commit e31c3b5246
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()