diff --git a/library/httpserver/httpserver.go b/library/httpserver/httpserver.go index 90be0c2b..b6178d80 100644 --- a/library/httpserver/httpserver.go +++ b/library/httpserver/httpserver.go @@ -21,12 +21,9 @@ const ( ) func StartHttpServer(srv *http.Server, cfg *configcenter.DefaultConfig, ip string, port int) { - quit := make(chan os.Signal) - go func() { if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { logger.Fatal("listen: %v", err) - quit <- syscall.SIGTERM return } @@ -36,12 +33,13 @@ func StartHttpServer(srv *http.Server, cfg *configcenter.DefaultConfig, ip strin go func() { err := registerSD(ip, port) if err != nil { - quit <- syscall.SIGTERM + logger.Fatal("registerSD: %v", err) return } setServerStatusFD(ServerStatusFDRun) }() + quit := make(chan os.Signal) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit logger.Info("Shutdown Server ...")