Merge pull request 'conflict' (#483) from conflict into test
Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/483
This commit is contained in:
commit
454d7d389b
|
@ -116,7 +116,7 @@ func main() {
|
||||||
Addr: fmt.Sprintf("%s:%d", ip, port),
|
Addr: fmt.Sprintf("%s:%d", ip, port),
|
||||||
Handler: router,
|
Handler: router,
|
||||||
}
|
}
|
||||||
httpserver.StartHttpServer(srv, cfg.OfflineServer, ip, port)
|
httpserver.StartOfflineHttpServer(srv, cfg.OfflineServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrintAndExit(msg string) {
|
func PrintAndExit(msg string) {
|
||||||
|
|
|
@ -100,3 +100,31 @@ func setServerStatusFD(status string) {
|
||||||
}
|
}
|
||||||
logger.Info("SetServerStatusFD success: %v", status)
|
logger.Info("SetServerStatusFD success: %v", status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func StartOfflineHttpServer(srv *http.Server, cfg *configcenter.DefaultConfig) {
|
||||||
|
go func() {
|
||||||
|
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||||
|
logger.Fatal("listen: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
logger.Info("Server %s start at %s", cfg.App.AppName, srv.Addr)
|
||||||
|
|
||||||
|
quit := make(chan os.Signal)
|
||||||
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
<-quit
|
||||||
|
logger.Info("Shutdown Server ...")
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
if err := srv.Shutdown(ctx); err != nil {
|
||||||
|
log.Fatal("Server Shutdown:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
logger.Info("timeout of 1 seconds.")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Info("Server exited")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue