瀏覽代碼

Move health response before semaphore

DarthSim 6 年之前
父節點
當前提交
c03a9c69c3
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      server.go

+ 6 - 6
server.go

@@ -212,6 +212,12 @@ func (h *httpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
 		panic(errInvalidSecret)
 	}
 
+	if r.URL.RequestURI() == healthPath {
+		rw.WriteHeader(200)
+		rw.Write(imgproxyIsRunningMsg)
+		return
+	}
+
 	ctx := context.Background()
 
 	if newRelicEnabled {
@@ -228,12 +234,6 @@ func (h *httpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
 	h.lock()
 	defer h.unlock()
 
-	if r.URL.RequestURI() == healthPath {
-		rw.WriteHeader(200)
-		rw.Write(imgproxyIsRunningMsg)
-		return
-	}
-
 	ctx, timeoutCancel := startTimer(ctx, time.Duration(conf.WriteTimeout)*time.Second)
 	defer timeoutCancel()