From 0fccf8f9394f7e07faa6b99b50614af17c50fd37 Mon Sep 17 00:00:00 2001 From: Anisur Rahman Date: Fri, 24 May 2024 12:42:57 +0600 Subject: [PATCH] sqlserver: special url for proxy health-checks Signed-off-by: Anisur Rahman --- internal/databases/sqlserver/blob/server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/databases/sqlserver/blob/server.go b/internal/databases/sqlserver/blob/server.go index 1d989c2eb..b1dae4145 100644 --- a/internal/databases/sqlserver/blob/server.go +++ b/internal/databases/sqlserver/blob/server.go @@ -38,6 +38,8 @@ const BlockReadCacheSize = 16 const MaxCacheBlockSize = 16 * 1024 * 1024 // 16M +const InternalPingURL = "/__walg_g_ping__" + type Server struct { folder storage.Folder certFile string @@ -150,7 +152,7 @@ func (bs *Server) RunBackground(ctx context.Context, cancel context.CancelFunc) func (bs *Server) WaitReady(ctx context.Context, timeout time.Duration) error { sctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - url := fmt.Sprintf("https://%s/", bs.endpoint) + url := fmt.Sprintf("https://%s%s", bs.endpoint, InternalPingURL) c := http.Client{Timeout: 100 * time.Millisecond} t := time.NewTicker(200 * time.Millisecond) for { @@ -207,6 +209,10 @@ func (bs *Server) ServeHTTP2(w http.ResponseWriter, req *http.Request) { w.WriteHeader(http.StatusInternalServerError) } }() + if req.URL.Path == InternalPingURL { + w.WriteHeader(http.StatusOK) + return + } // default headers w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Length", "0")