move signal handler to other handlers
This commit is contained in:
parent
c45551178a
commit
be54136c5c
|
@ -306,15 +306,6 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, os.Interrupt)
|
||||
go func() {
|
||||
for _ = range sigChan {
|
||||
d.Close()
|
||||
os.Exit(int(syscall.SIGINT))
|
||||
}
|
||||
}()
|
||||
|
||||
if c.AutoNat {
|
||||
var opts []libp2p.Option
|
||||
// allow the AutoNAT service to dial back quic addrs.
|
||||
|
|
|
@ -11,13 +11,22 @@ import (
|
|||
|
||||
func (d *Daemon) trapSignals() {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGUSR1)
|
||||
signal.Notify(ch, syscall.SIGUSR1, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT)
|
||||
for {
|
||||
select {
|
||||
case s := <-ch:
|
||||
switch s {
|
||||
case syscall.SIGUSR1:
|
||||
d.handleSIGUSR1()
|
||||
case syscall.SIGINT:
|
||||
d.Close()
|
||||
os.Exit(int(syscall.SIGINT))
|
||||
case syscall.SIGTERM:
|
||||
d.Close()
|
||||
os.Exit(int(syscall.SIGTERM))
|
||||
case syscall.SIGABRT:
|
||||
d.Close()
|
||||
os.Exit(int(syscall.SIGABRT))
|
||||
default:
|
||||
log.Warningf("unexpected signal %d", s)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue