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