shut down rpc server before node

This commit is contained in:
whyrusleeping 2019-10-20 15:17:03 +09:00
parent 1641ee48a1
commit cc689ab920

View File

@ -33,12 +33,12 @@ func serveRPC(a api.FullNode, stop node.StopFunc, addr string) error {
sigChan := make(chan os.Signal, 2)
go func() {
<-sigChan
if err := stop(context.TODO()); err != nil {
log.Errorf("graceful shutting down failed: %s", err)
}
if err := srv.Shutdown(context.TODO()); err != nil {
log.Errorf("shutting down RPC server failed: %s", err)
}
if err := stop(context.TODO()); err != nil {
log.Errorf("graceful shutting down failed: %s", err)
}
}()
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT)