fix: bind uvicorn to Railway's dynamic $PORT (prod deploy healthcheck failure)#319
Conversation
Railway assigns a dynamic $PORT and runs its healthcheck against it. The Dockerfile hardcoded --port 8000, so every deploy after healthcheckPath was added to railway.json failed with "service unavailable" on /health. OpenCodeIntel#316 and OpenCodeIntel#318 have both been stuck for days; prod only survived on the pre-healthcheck OpenCodeIntel#293 image until that replica was knocked out. Bind ${PORT:-8000} (fallback for local/compose) and make the internal healthcheck read the same port.
|
@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request modifies ChangesDynamic Port Support
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Problem
Production backend (api.opencodeintel.com) was returning 502
Application failed to respondon every route. The browser surfaced it as a CORS error (noAccess-Control-Allow-Origin), but the API was simply not reachable: no healthy Railway replica.Root cause
The Railway deploy was failing at the healthcheck step, not at boot. Deploy logs show the app starts fine (
Uvicorn running on http://0.0.0.0:8000,Application startup complete), but/healthreturns "service unavailable" on all 11 attempts.backend/Dockerfilehardcoded--port 8000. Railway assigns a dynamic$PORTand runs its platform healthcheck (healthcheckPath: /healthinrailway.json) against that port. Nothing listens there, so the healthcheck never passes and the deploy is rejected.This was a latent bug:
healthcheckPathwas added torailway.jsonafter the last good deploy (#293), so #293 served fine on 8000 with no healthcheck enforcing reachability. Every deploy since (#316, #318) hit this and failed silently for days; prod only stayed up on the stale #293 image until that replica was replaced.Fix
Bind uvicorn to
${PORT:-8000}(fallback preserves local/docker-compose), and make the internal Docker healthcheck read the same port.execkeeps uvicorn as PID 1 for graceful SIGTERM shutdown.CMD exec uvicorn main:app --host 0.0.0.0 --port ${PORT:-8000} --proxy-headersNote for reviewer / on merge
This fix unblocks the deploy pipeline, so merging it will deploy the backend changes from #316 (durable repo-state) and #318 (eval harness) to prod for the first time — they were merged to main but never actually shipped because of this bug. Both passed CI/CodeRabbit; flagging so the first green deploy is expected to carry that code.
Testing
${PORT:-8000}expansion verified (set -> dynamic port, unset -> 8000).Summary by CodeRabbit