feat(health): enhance health check to report database connection status #109
+76
−6
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.
Motivation and Context
Previously, the /v0/health endpoint only indicated if the service was running, without verifying database connectivity. This could result in false positives where the service appears healthy even if the database is down.
With this change, the health endpoint now checks the actual database connection and reports a "db_error" status with a 503 response if the database is unavailable. This provides more accurate health monitoring for deployments and automated systems, enabling better reliability and faster detection of backend issues.
How Has This Been Tested?
The endpoint was tested using the provided test script (test_endpoints.sh) and by running the application with and without a reachable database to verify real-world behaviour.
Breaking Changes
No, users do not need to update their code or configurations. The health check endpoint remains at the same URL and accepts the same requests.
Types of changes
Checklist
Additional context
I have started my journey for the first time doing a contribution. Thanks to all for your support.