@@ -40,9 +40,12 @@ func RunInternalServer(ctx context.Context, configs config.Config, healthDeps *H
4040 mux := http .NewServeMux ()
4141 if configs .GetBool ("internalApi.healthcheck.enabled" ) {
4242 zap .L ().Info ("adding healthcheck handler to internal API" )
43+ if configs .GetBool ("internalApi.healthcheck.skipPostgresCheck" ) {
44+ zap .L ().Warn ("PostgreSQL health check is DISABLED - /readyz will not check database connectivity" )
45+ }
4346 mux .HandleFunc ("/health" , handleHealth )
4447 mux .HandleFunc ("/healthz" , handleHealth )
45- mux .HandleFunc ("/readyz" , handleReadyz (healthDeps ))
48+ mux .HandleFunc ("/readyz" , handleReadyz (configs , healthDeps ))
4649 }
4750 if configs .GetBool ("internalApi.metrics.enabled" ) {
4851 zap .L ().Info ("adding metrics handler to internal API" )
@@ -70,11 +73,14 @@ func RunInternalServer(ctx context.Context, configs config.Config, healthDeps *H
7073 }
7174}
7275
73- func handleReadyz (deps * HealthDependencies ) http.HandlerFunc {
76+ func handleReadyz (c config. Config , deps * HealthDependencies ) http.HandlerFunc {
7477 return func (w http.ResponseWriter , r * http.Request ) {
7578 healthy := true
7679
77- if deps .PostgresDB != nil {
80+ // Skip PostgreSQL check if configured
81+ skipPostgresCheck := c .GetBool ("internalApi.healthcheck.skipPostgresCheck" )
82+
83+ if ! skipPostgresCheck && deps .PostgresDB != nil {
7884 if err := checkPostgres (r .Context (), deps .PostgresDB ); err != nil {
7985 healthy = false
8086 }
@@ -86,11 +92,14 @@ func handleReadyz(deps *HealthDependencies) http.HandlerFunc {
8692 }
8793 }
8894
95+ w .Header ().Set ("Content-Type" , "text/plain; charset=utf-8" )
96+
8997 if ! healthy {
9098 w .WriteHeader (http .StatusServiceUnavailable )
99+ _ , _ = w .Write ([]byte ("Service Unavailable" ))
100+ return
91101 }
92102
93- w .Header ().Set ("Content-Type" , "text/plain; charset=utf-8" )
94103 w .WriteHeader (http .StatusOK )
95104 _ , _ = w .Write ([]byte ("OK" ))
96105 }
0 commit comments