Merge branch 'master' into kd-live
This commit is contained in:
10
server.go
10
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")
|
||||
|
||||
Reference in New Issue
Block a user