Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: add healthz endpoint (#1138)

Danny Xua63790cfa9ea
diff --git a/Dockerfile b/Dockerfile
index 4347d7e510..9ff0d4d14a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -74,4 +74,6 @@ RUN mkdir -p /var/opt/bytebase
CMD ["--host", "http://localhost", "--port", "80", "--data", "/var/opt/bytebase"]
+HEALTHCHECK --interval=5m --timeout=60s CMD curl -f http://localhost:80/healthz || exit 1
+
ENTRYPOINT ["bytebase"]
diff --git a/Dockerfile.render-demo b/Dockerfile.render-demo
index 5363f56182..e6f16f56ca 100644
--- a/Dockerfile.render-demo
+++ b/Dockerfile.render-demo
@@ -74,4 +74,6 @@ RUN mkdir -p /var/opt/bytebase
CMD ["--host", "http://localhost", "--port", "80", "--data", "/var/opt/bytebase"]
+HEALTHCHECK --interval=5m --timeout=60s CMD curl -f http://localhost:80/healthz || exit 1
+
ENTRYPOINT ["bytebase"]
diff --git a/server/server.go b/server/server.go
index bfea0d9fa6..200b4af7b7 100644
--- a/server/server.go
+++ b/server/server.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "net/http"
"strings"
"sync"
"time"
@@ -236,6 +237,10 @@ func NewServer(logger *zap.Logger, storeInstance *store.Store, loggerLevel *zap.
s.registerLabelRoutes(apiGroup)
s.registerSubscriptionRoutes(apiGroup)
s.registerSheetRoutes(apiGroup)
+ // Register healthz endpoint.
+ e.GET("/healthz", func(c echo.Context) error {
+ return c.String(http.StatusOK, "OK!\n")
+ })
allRoutes, err := json.MarshalIndent(e.Routes(), "", " ")
if err != nil {