healthCheckHandler 로그 추가

This commit is contained in:
2023-07-10 17:15:59 +09:00
parent 8b74f50a1d
commit a9de99b04a

View File

@ -73,7 +73,10 @@ func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
// 한번이라도 들어오면 lb에 붙어있다는 뜻
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)
}
}
@ -127,11 +130,18 @@ func (server *Server) shutdown() {
signal.Stop(server.interrupt)
if atomic.LoadInt64(&healthcheckcounter) > 0 {
atomic.StoreInt64(&healthcheckcounter, math.MinInt64)
for atomic.LoadInt64(&healthcheckcounter)-math.MinInt64 == 0 {
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)
time.Sleep(100 * time.Millisecond)
}
logger.Println("http server shutdown. healthcheck completed")
} else {
logger.Println("http server shutdown. no lb")
}
if server.httpserver != nil {