Conversation
…ver never starts An app that registers readiness checks via AddReadinessCheck but registers no HTTP routes — and has no public/ directory — starts metrics-only: Run() skips startHTTPServer because httpRegistered is false, no port is bound, and /.well-known/health is never served. Nothing in the startup log says why, so the app looks healthy while every readiness probe gets connection refused. startHTTPServer now logs a warning when it detects exactly that mismatch (readiness checks registered, HTTP server not marked for startup), pointing at the fix — register at least one HTTP route. Apps without readiness checks are unaffected and stay silent. Covered by TestApp_startHTTPServer_warnsWhenReadinessChecksCannotBeServed. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4259.
Problem
An app that registers readiness checks but no HTTP routes never starts its HTTP server — silently:
Run()gatesstartHTTPServeronhttpRegistered, which is set only by route registration (GET/POST/GraphQL/CRUD) or the presence of apublic/static directory. With no routes and nopublic/, no port is bound,/.well-known/healthis never served, and the startup log shows a perfectly healthy metrics server — while every readiness probe gets connection refused. Nothing says why.The check-only app is unusual, but the failure is invisible when it happens: the metrics-port line in the log looks exactly like a normal startup.
Fix
startHTTPServernow logs a warning when it detects exactly that mismatch — readiness checks registered, HTTP server not marked for startup:The wording mirrors the existing
readiness: N app check(s) registeredinfo line, so both ends of the story read the same. Apps without readiness checks are unaffected and stay silent, so normal no-HTTP usage (pure metrics, gRPC-only, CMD) sees no new output.Behavior change
None beyond the new WARN line: no API change, no config change, no startup-time cost for apps without readiness checks (the check is one nil-slice length read on a path that previously did nothing).
Verification
TestApp_startHTTPServer_warnsWhenReadinessChecksCannotBeServeddrives the realstartHTTPServer: warns with checks + no routes, stays silent with neither. It pinshttpRegisteredexplicitly becauseNew()marks the server for startup whenever the working directory happens to contain a static directory — a workspace-dependent test would be flaky./pingroute added back, the warning disappears and health serves normally.go vet ./pkg/gofr/clean;gofmtclean.Checklist