more efficient cleanup, lessons learned

This commit is contained in:
Jesse de Wit
2022-12-23 18:23:38 +01:00
parent 5922b7e73d
commit 6e673d2be4
4 changed files with 79 additions and 32 deletions

11
main.go
View File

@@ -4,7 +4,9 @@ import (
"fmt"
"log"
"os"
"os/signal"
"sync"
"syscall"
"github.com/btcsuite/btcd/btcec/v2"
)
@@ -86,6 +88,15 @@ func main() {
wg.Done()
}()
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
sig := <-c
log.Printf("Received stop signal %v. Stopping.", sig)
s.Stop()
interceptor.Stop()
}()
wg.Wait()
log.Printf("lspd exited")
}