Defer srv.Stop after successful call of srv.Start.
This commit is contained in:
parent
f22fa1ee1d
commit
7915091b96
@ -78,16 +78,16 @@ func main() {
|
|||||||
r.Handler(http.MethodGet, "/favicon.svg", duihttp.Favicon)
|
r.Handler(http.MethodGet, "/favicon.svg", duihttp.Favicon)
|
||||||
|
|
||||||
srv := duihttp.NewHttpServer(r)
|
srv := duihttp.NewHttpServer(r)
|
||||||
|
|
||||||
|
if err := srv.Start(*listenAddress); err != nil {
|
||||||
|
log.Fatalln("failed to start a server:", err)
|
||||||
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := srv.Stop(); err != nil {
|
if err := srv.Stop(); err != nil {
|
||||||
log.Fatalln("failed to properly shutdown a server:", err)
|
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)
|
doneSignal := make(chan os.Signal, 1)
|
||||||
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user