feat: support --abort for reload and suspend (#346)

This commit is contained in:
mzz
2023-11-14 16:26:33 +08:00
committed by GitHub
parent 7e57531f91
commit 9f7a49b81d
5 changed files with 39 additions and 1 deletions

View File

@ -108,6 +108,8 @@ var (
)
func Run(log *logrus.Logger, conf *config.Config, externGeoDataDirs []string) (err error) {
// Remove AbortFile at beginning.
_ = os.Remove(AbortFile)
// New ControlPlane.
c, err := newControlPlane(log, nil, nil, conf, externGeoDataDirs)
@ -135,6 +137,7 @@ func Run(log *logrus.Logger, conf *config.Config, externGeoDataDirs []string) (e
}()
reloading := false
isSuspend := false
abortConnections := false
loop:
for sig := range sigs {
switch sig {
@ -174,6 +177,7 @@ loop:
sdnotify.Reloading()
// Load new config.
abortConnections = os.Remove(AbortFile) == nil
log.Warnln("[Reload] Load new config")
var newConf *config.Config
if isSuspend {
@ -247,6 +251,9 @@ loop:
reloading = true
// Ready to close.
if abortConnections {
oldC.AbortConnections()
}
oldC.Close()
case syscall.SIGHUP:
// Ignore.