From a04e46f71983ba8bb5c8056ac232a158aacf8e90 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 30 Apr 2021 15:53:27 +0300 Subject: [PATCH 1/2] cli: reload RPC-server TLS config on SIGHUP --- cli/server/server.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cli/server/server.go b/cli/server/server.go index daf0438e3..e0899ec52 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "os/signal" + "syscall" "github.com/nspcc-dev/neo-go/cli/options" "github.com/nspcc-dev/neo-go/pkg/config" @@ -325,6 +326,9 @@ func startServer(ctx *cli.Context) error { go serv.Start(errChan) rpcServer.Start(errChan) + sighupCh := make(chan os.Signal, 1) + signal.Notify(sighupCh, syscall.SIGHUP) + fmt.Fprintln(ctx.App.Writer, logo()) fmt.Fprintln(ctx.App.Writer, serv.UserAgent) fmt.Fprintln(ctx.App.Writer) @@ -336,8 +340,20 @@ Main: case err := <-errChan: shutdownErr = fmt.Errorf("server error: %w", err) cancel() - + case sig := <-sighupCh: + switch sig { + case syscall.SIGHUP: + log.Info("SIGHUP received, restarting rpc-server") + serverErr := rpcServer.Shutdown() + if serverErr != nil { + errChan <- fmt.Errorf("error while restarting rpc-server: %w", serverErr) + break + } + rpcServer = server.New(chain, cfg.ApplicationConfiguration.RPC, serv, serv.GetOracle(), log) + rpcServer.Start(errChan) + } case <-grace.Done(): + signal.Stop(sighupCh) serv.Shutdown() if serverErr := rpcServer.Shutdown(); serverErr != nil { shutdownErr = fmt.Errorf("error on shutdown: %w", serverErr) From b5dc598af77a128f1f81fe0a19af64e3e01fd9c4 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 5 May 2021 10:57:31 +0300 Subject: [PATCH 2/2] docs: add docs on services restart --- docs/cli.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/cli.md b/docs/cli.md index c463dedad..675428acc 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -52,6 +52,15 @@ Or specify a different network with appropriate flag like this: By default the node will run in foreground using current standard output for logging. +### Restarting node services + +To restart some of the node services without full node restart, send the SIGHUP +signal. List of the services to be restarted on SIGHUP receiving: + +| Service | Action | +| --- | --- | +| RPC server | Restarting with the old configuration and updated TLS certificates | + ### DB import/exports Node operates using some database as a backend to store blockchain data. NeoGo