mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-16 19:00:05 +07:00
optimize: use sigusr2 to suspend instead of sighup
This commit is contained in:
10
cmd/run.go
10
cmd/run.go
@ -92,7 +92,7 @@ func Run(log *logrus.Logger, conf *config.Config, externGeoDataDirs []string) (e
|
||||
// Serve tproxy TCP/UDP server util signals.
|
||||
var listener *control.Listener
|
||||
sigs := make(chan os.Signal, 1)
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGKILL, syscall.SIGILL, syscall.SIGUSR1)
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGKILL, syscall.SIGILL, syscall.SIGUSR1, syscall.SIGUSR2)
|
||||
go func() {
|
||||
readyChan := make(chan bool, 1)
|
||||
go func() {
|
||||
@ -131,12 +131,16 @@ loop:
|
||||
// Listening error.
|
||||
break loop
|
||||
}
|
||||
case syscall.SIGHUP:
|
||||
case syscall.SIGUSR2:
|
||||
isSuspend = true
|
||||
fallthrough
|
||||
case syscall.SIGUSR1:
|
||||
// Reload signal.
|
||||
log.Warnln("[Reload] Received reload signal; prepare to reload")
|
||||
if isSuspend {
|
||||
log.Warnln("[Reload] Received suspend signal; prepare to suspend")
|
||||
} else {
|
||||
log.Warnln("[Reload] Received reload signal; prepare to reload")
|
||||
}
|
||||
sdnotify.Reloading()
|
||||
|
||||
// Load new config.
|
||||
|
@ -7,8 +7,8 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/daeuniverse/dae/cmd/internal"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -34,7 +34,7 @@ var (
|
||||
cmd.Help()
|
||||
os.Exit(1)
|
||||
}
|
||||
if err = syscall.Kill(pid, syscall.SIGHUP); err != nil {
|
||||
if err = syscall.Kill(pid, syscall.SIGUSR2); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -9,12 +9,12 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/daeuniverse/dae/common/consts"
|
||||
"github.com/daeuniverse/dae/common/netutils"
|
||||
"github.com/mzz2017/softwind/netproxy"
|
||||
"github.com/mzz2017/softwind/pkg/fastrand"
|
||||
"github.com/mzz2017/softwind/protocol/direct"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/daeuniverse/dae/common/consts"
|
||||
"github.com/daeuniverse/dae/common/netutils"
|
||||
"golang.org/x/net/dns/dnsmessage"
|
||||
"net"
|
||||
"net/http"
|
||||
@ -239,7 +239,7 @@ func (d *Dialer) aliveBackground() {
|
||||
d.Log.WithFields(logrus.Fields{
|
||||
"link": d.TcpCheckOptionRaw.Raw,
|
||||
"network": typ.String(),
|
||||
}).Debugln("Skip check due to no record.")
|
||||
}).Debugln("Skip check due to no DNS record.")
|
||||
return false, nil
|
||||
}
|
||||
return d.HttpCheck(ctx, opt.Url, opt.Ip4)
|
||||
@ -260,7 +260,7 @@ func (d *Dialer) aliveBackground() {
|
||||
d.Log.WithFields(logrus.Fields{
|
||||
"link": d.TcpCheckOptionRaw.Raw,
|
||||
"network": typ.String(),
|
||||
}).Debugln("Skip check due to no record.")
|
||||
}).Debugln("Skip check due to no DNS record.")
|
||||
return false, nil
|
||||
}
|
||||
return d.HttpCheck(ctx, opt.Url, opt.Ip6)
|
||||
@ -281,7 +281,7 @@ func (d *Dialer) aliveBackground() {
|
||||
d.Log.WithFields(logrus.Fields{
|
||||
"link": d.CheckDnsOptionRaw.Raw,
|
||||
"network": typ.String(),
|
||||
}).Debugln("Skip check due to no record.")
|
||||
}).Debugln("Skip check due to no DNS record.")
|
||||
return false, nil
|
||||
}
|
||||
return d.DnsCheck(ctx, netip.AddrPortFrom(opt.Ip4, opt.DnsPort), true)
|
||||
@ -302,7 +302,7 @@ func (d *Dialer) aliveBackground() {
|
||||
d.Log.WithFields(logrus.Fields{
|
||||
"link": d.CheckDnsOptionRaw.Raw,
|
||||
"network": typ.String(),
|
||||
}).Debugln("Skip check due to no record.")
|
||||
}).Debugln("Skip check due to no DNS record.")
|
||||
return false, nil
|
||||
}
|
||||
return d.DnsCheck(ctx, netip.AddrPortFrom(opt.Ip6, opt.DnsPort), true)
|
||||
@ -323,7 +323,7 @@ func (d *Dialer) aliveBackground() {
|
||||
d.Log.WithFields(logrus.Fields{
|
||||
"link": d.CheckDnsOptionRaw.Raw,
|
||||
"network": typ.String(),
|
||||
}).Debugln("Skip check due to no record.")
|
||||
}).Debugln("Skip check due to no DNS record.")
|
||||
return false, nil
|
||||
}
|
||||
return d.DnsCheck(ctx, netip.AddrPortFrom(opt.Ip4, opt.DnsPort), false)
|
||||
@ -344,7 +344,7 @@ func (d *Dialer) aliveBackground() {
|
||||
d.Log.WithFields(logrus.Fields{
|
||||
"link": d.CheckDnsOptionRaw.Raw,
|
||||
"network": typ.String(),
|
||||
}).Debugln("Skip check due to no record.")
|
||||
}).Debugln("Skip check due to no DNS record.")
|
||||
return false, nil
|
||||
}
|
||||
return d.DnsCheck(ctx, netip.AddrPortFrom(opt.Ip6, opt.DnsPort), false)
|
||||
|
Reference in New Issue
Block a user