Check configuration before reload

This commit is contained in:
世界 2022-08-23 23:22:49 +08:00
parent 1413c5022a
commit 88469d4aaa
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -79,19 +79,29 @@ func create() (*box.Box, context.CancelFunc, error) {
} }
func run() error { func run() error {
osSignals := make(chan os.Signal, 1)
signal.Notify(osSignals, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
for { for {
instance, cancel, err := create() instance, cancel, err := create()
if err != nil { if err != nil {
return err return err
} }
runtimeDebug.FreeOSMemory() runtimeDebug.FreeOSMemory()
osSignals := make(chan os.Signal, 1) for {
signal.Notify(osSignals, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP) osSignal := <-osSignals
osSignal := <-osSignals if osSignal == syscall.SIGHUP {
cancel() err = check()
instance.Close() if err != nil {
if osSignal != syscall.SIGHUP { log.Error(E.Cause(err, "reload service"))
return nil continue
}
}
cancel()
instance.Close()
if osSignal != syscall.SIGHUP {
return nil
}
break
} }
} }
} }