aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-14 00:22:15 +0800
committerGitHub <noreply@github.com>2017-02-14 00:22:15 +0800
commit9b161187ec130841bf4d04945cdcf45c221739fc (patch)
tree8af47183d07f664ab821a677401bc11a1b67db89
parent0850f68fd17586370b102aa516739476db4913c2 (diff)
parent8883f36fe38fc9701f707f9cac8ebcb34d418c46 (diff)
downloadgo-tangerine-9b161187ec130841bf4d04945cdcf45c221739fc.tar
go-tangerine-9b161187ec130841bf4d04945cdcf45c221739fc.tar.gz
go-tangerine-9b161187ec130841bf4d04945cdcf45c221739fc.tar.bz2
go-tangerine-9b161187ec130841bf4d04945cdcf45c221739fc.tar.lz
go-tangerine-9b161187ec130841bf4d04945cdcf45c221739fc.tar.xz
go-tangerine-9b161187ec130841bf4d04945cdcf45c221739fc.tar.zst
go-tangerine-9b161187ec130841bf4d04945cdcf45c221739fc.zip
Merge pull request #3649 from ethersphere/swarm-sigterm-fix
cmd/swarm: handle SIGTERM unix signal for clean exit
-rw-r--r--cmd/swarm/main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go
index 14adc3b10..5661b3f6e 100644
--- a/cmd/swarm/main.go
+++ b/cmd/swarm/main.go
@@ -21,9 +21,11 @@ import (
"fmt"
"io/ioutil"
"os"
+ "os/signal"
"runtime"
"strconv"
"strings"
+ "syscall"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
@@ -271,6 +273,14 @@ func bzzd(ctx *cli.Context) error {
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
registerBzzService(ctx, stack)
utils.StartNode(stack)
+ go func() {
+ sigc := make(chan os.Signal, 1)
+ signal.Notify(sigc, syscall.SIGTERM)
+ defer signal.Stop(sigc)
+ <-sigc
+ glog.V(logger.Info).Infoln("Got sigterm, shutting down...")
+ stack.Stop()
+ }()
networkId := ctx.GlobalUint64(SwarmNetworkIdFlag.Name)
// Add bootnodes as initial peers.
if ctx.GlobalIsSet(utils.BootnodesFlag.Name) {