fix: restful server restart

This commit is contained in:
wwqgtxx 2024-09-10 16:43:00 +08:00
parent 7c8f451892
commit 89b9438fc0

View File

@ -148,10 +148,10 @@ func start(cfg *Config) {
server := &http.Server{ server := &http.Server{
Handler: router(cfg.IsDebug, cfg.Secret, cfg.DohServer), Handler: router(cfg.IsDebug, cfg.Secret, cfg.DohServer),
} }
httpServer = server
if err = server.Serve(l); err != nil { if err = server.Serve(l); err != nil {
log.Errorln("External controller serve error: %s", err) log.Errorln("External controller serve error: %s", err)
} }
httpServer = server
} }
} }
@ -183,10 +183,10 @@ func startTLS(cfg *Config) {
Certificates: []tls.Certificate{c}, Certificates: []tls.Certificate{c},
}, },
} }
tlsServer = server
if err = server.ServeTLS(l, "", ""); err != nil { if err = server.ServeTLS(l, "", ""); err != nil {
log.Errorln("External controller tls serve error: %s", err) log.Errorln("External controller tls serve error: %s", err)
} }
tlsServer = server
} }
} }
@ -228,10 +228,10 @@ func startUnix(cfg *Config) {
server := &http.Server{ server := &http.Server{
Handler: router(cfg.IsDebug, "", cfg.DohServer), Handler: router(cfg.IsDebug, "", cfg.DohServer),
} }
unixServer = server
if err = server.Serve(l); err != nil { if err = server.Serve(l); err != nil {
log.Errorln("External controller unix serve error: %s", err) log.Errorln("External controller unix serve error: %s", err)
} }
unixServer = server
} }
} }