healthcheck 수정

This commit is contained in:
2023-07-10 17:46:05 +09:00
parent a9de99b04a
commit b759f13eee

View File

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"math"
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
@ -75,8 +74,6 @@ func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
if t := atomic.AddInt64(&healthcheckcounter, 1); t < 0 { if t := atomic.AddInt64(&healthcheckcounter, 1); t < 0 {
logger.Println("healthCheckHandler return StatusServiceUnavailable :", t) logger.Println("healthCheckHandler return StatusServiceUnavailable :", t)
w.WriteHeader(http.StatusServiceUnavailable) 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 { if t := atomic.LoadInt64(&healthcheckcounter); t > 0 {
logger.Println("http server shutdown. healthcheckcounter :", t) logger.Println("http server shutdown. healthcheckcounter :", t)
t = math.MinInt64 atomic.StoreInt64(&healthcheckcounter, -100000000)
atomic.StoreInt64(&healthcheckcounter, t) for t = -100000000; t+100000000 < 10; t = atomic.LoadInt64(&healthcheckcounter) {
for ; t-math.MinInt64 > 0; t = atomic.LoadInt64(&healthcheckcounter) { logger.Println(" waiting for healthcheckcounter increase y lb", t+100000000)
logger.Println(" waiting for healthcheckcounter increase y lb", t-math.MinInt64)
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
} }
logger.Println("http server shutdown. healthcheck completed") logger.Println("http server shutdown. healthcheck completed")