mirror of
https://github.com/aljazceru/lspd.git
synced 2025-12-19 14:54:22 +01:00
more efficient cleanup, lessons learned
This commit is contained in:
11
main.go
11
main.go
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user