1
0

Defer srv.Stop after successful call of srv.Start.

This commit is contained in:
Alexander Andreev 2023-08-06 03:00:31 +04:00
parent f22fa1ee1d
commit 7915091b96
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -78,16 +78,16 @@ func main() {
r.Handler(http.MethodGet, "/favicon.svg", duihttp.Favicon)
srv := duihttp.NewHttpServer(r)
if err := srv.Start(*listenAddress); err != nil {
log.Fatalln("failed to start a server:", err)
}
defer func() {
if err := srv.Stop(); err != nil {
log.Fatalln("failed to properly shutdown a server:", err)
}
}()
if err := srv.Start(*listenAddress); err != nil {
log.Fatalln("failed to start a server:", err)
}
doneSignal := make(chan os.Signal, 1)
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)