From b759f13eeeb69f57bb9eac0e35672757f4e38639 Mon Sep 17 00:00:00 2001 From: mountain Date: Mon, 10 Jul 2023 17:46:05 +0900 Subject: [PATCH] =?UTF-8?q?healthcheck=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server.go b/server.go index 27c5da9..8560463 100644 --- a/server.go +++ b/server.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "math" "net" "net/http" "net/url" @@ -75,8 +74,6 @@ func healthCheckHandler(w http.ResponseWriter, r *http.Request) { if t := atomic.AddInt64(&healthcheckcounter, 1); t < 0 { logger.Println("healthCheckHandler return StatusServiceUnavailable :", t) w.WriteHeader(http.StatusServiceUnavailable) - } else { - logger.Println("healthCheckHandler return StatusOK :", t) } } @@ -133,10 +130,9 @@ func (server *Server) shutdown() { if t := atomic.LoadInt64(&healthcheckcounter); t > 0 { logger.Println("http server shutdown. healthcheckcounter :", t) - t = math.MinInt64 - atomic.StoreInt64(&healthcheckcounter, t) - for ; t-math.MinInt64 > 0; t = atomic.LoadInt64(&healthcheckcounter) { - logger.Println(" waiting for healthcheckcounter increase y lb", t-math.MinInt64) + atomic.StoreInt64(&healthcheckcounter, -100000000) + for t = -100000000; t+100000000 < 10; t = atomic.LoadInt64(&healthcheckcounter) { + logger.Println(" waiting for healthcheckcounter increase y lb", t+100000000) time.Sleep(100 * time.Millisecond) } logger.Println("http server shutdown. healthcheck completed")