fix signal handling

This commit is contained in:
mykola2312 2025-01-24 02:50:22 +02:00
parent 10266f26ef
commit 54dcd30a3f

14
main.go
View file

@ -103,6 +103,10 @@ func nodeMain() {
// load keystore
ks := crypto.NewLuxKeyStore(config.KeyStore)
if err := ks.Load(); err != nil {
fmt.Fprintf(os.Stderr, "failed to laod keystore: %v\n", err)
os.Exit(1)
}
nodeKey, ok := ks.Get(nodeId)
if !ok {
@ -175,16 +179,20 @@ func nodeMain() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
signaling:
for {
sig := <-sigs
fmt.Println(sig)
switch sig {
case syscall.SIGINT:
break signaling
case syscall.SIGTERM:
// stop node daemon
node.Stop()
os.Exit(0)
break signaling
}
}
// stop daemon
node.Stop()
}
func main() {