handle clean shutdown

This commit is contained in:
Jesse de Wit
2023-01-23 14:54:55 +01:00
parent 294080b067
commit 5aad6b313e
6 changed files with 26 additions and 4 deletions

View File

@@ -2,11 +2,20 @@ package main
import (
"os"
"os/signal"
"syscall"
"github.com/breez/lspd/cln_plugin"
)
func main() {
plugin := cln_plugin.NewClnPlugin(os.Stdin, os.Stdout)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-c
// Stop everything gracefully on stop signal
plugin.Stop()
}()
plugin.Start()
}