diff --git a/node/health.go b/node/health.go index a92997a61..9e9f3bb80 100644 --- a/node/health.go +++ b/node/health.go @@ -10,15 +10,19 @@ import ( ) type HealthHandler struct { - healthy bool + healthy int32 } func (h *HealthHandler) SetHealthy(healthy bool) { - h.healthy = healthy + h := int32(0) + if healthy { + h = 1 + } + atomic.StoreInt32(&h.healthy, h) } func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if !h.healthy { + if atomic.LoadInt32(&h.healthy) != 1 { w.WriteHeader(http.StatusServiceUnavailable) return }