Merge branch 'master' into kd-live
This commit is contained in:
16
server.go
16
server.go
@ -73,7 +73,10 @@ func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// 한번이라도 들어오면 lb에 붙어있다는 뜻
|
// 한번이라도 들어오면 lb에 붙어있다는 뜻
|
||||||
if t := atomic.AddInt64(&healthcheckcounter, 1); t < 0 {
|
if t := atomic.AddInt64(&healthcheckcounter, 1); t < 0 {
|
||||||
|
logger.Println("healthCheckHandler return StatusServiceUnavailable :", t)
|
||||||
w.WriteHeader(http.StatusServiceUnavailable)
|
w.WriteHeader(http.StatusServiceUnavailable)
|
||||||
|
} else {
|
||||||
|
logger.Println("healthCheckHandler return StatusOK :", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,11 +130,18 @@ func (server *Server) shutdown() {
|
|||||||
|
|
||||||
signal.Stop(server.interrupt)
|
signal.Stop(server.interrupt)
|
||||||
|
|
||||||
if atomic.LoadInt64(&healthcheckcounter) > 0 {
|
if t := atomic.LoadInt64(&healthcheckcounter); t > 0 {
|
||||||
atomic.StoreInt64(&healthcheckcounter, math.MinInt64)
|
logger.Println("http server shutdown. healthcheckcounter :", t)
|
||||||
for atomic.LoadInt64(&healthcheckcounter)-math.MinInt64 == 0 {
|
|
||||||
|
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)
|
time.Sleep(100 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
logger.Println("http server shutdown. healthcheck completed")
|
||||||
|
} else {
|
||||||
|
logger.Println("http server shutdown. no lb")
|
||||||
}
|
}
|
||||||
|
|
||||||
if server.httpserver != nil {
|
if server.httpserver != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user