Skip to content

fix: wrap Railway startCommand in sh -c so $PORT expands#22

Merged
timothylee58 merged 1 commit into
mainfrom
claude/funny-johnson-bVave
May 25, 2026
Merged

fix: wrap Railway startCommand in sh -c so $PORT expands#22
timothylee58 merged 1 commit into
mainfrom
claude/funny-johnson-bVave

Conversation

@timothylee58

@timothylee58 timothylee58 commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

Railway does not shell-interpolate env vars in startCommand$PORT was passed literally to uvicorn, which rejected it as a non-integer.

Fix: wrap in sh -c '...' so the shell expands $PORT before uvicorn sees it.

startCommand = "sh -c 'uvicorn app.main:app --host 0.0.0.0 --port $PORT --workers 2'"

Also remove the custom start command from the Railway dashboard if one is set there — railway.toml takes precedence when deployed via Dockerfile builder.

https://claude.ai/code/session_017cLXjZu6kkjXRf2BemMPpp


Generated by Claude Code


Summary by cubic

Fix Railway deploys by wrapping the startCommand in sh -c so $PORT expands at runtime. Uvicorn now binds to the platform-assigned port instead of a hardcoded value.

  • Migration
    • If a custom start command exists in the Railway dashboard, remove it. railway.toml is used for Dockerfile builds.

Written for commit 5f4bbe6. Summary will update on new commits. Review in cubic

Railway does not shell-expand env vars in startCommand directly;
wrapping with sh -c ensures \$PORT is substituted at runtime.

https://claude.ai/code/session_017cLXjZu6kkjXRf2BemMPpp
@netlify

netlify Bot commented May 25, 2026

Copy link
Copy Markdown

Deploy Preview for bajet-buddy canceled.

Name Link
🔨 Latest commit 5f4bbe6
🔍 Latest deploy log https://app.netlify.com/projects/bajet-buddy/deploys/6a1404f4c78c360008d81a8c

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
bajet-buddy 5f4bbe6 May 25 2026, 08:15 AM

@timothylee58
timothylee58 marked this pull request as ready for review May 25, 2026 08:15
@timothylee58
timothylee58 merged commit f1e8d84 into main May 25, 2026
6 of 7 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the railway.toml configuration to use the $PORT environment variable for the uvicorn server instead of a hardcoded value. The review feedback suggests using exec to ensure the application correctly receives termination signals and providing a default value for the port variable to improve reliability.

Comment thread apps/api/railway.toml

[deploy]
startCommand = "uvicorn app.main:app --host 0.0.0.0 --port 8080 --workers 2"
startCommand = "sh -c 'uvicorn app.main:app --host 0.0.0.0 --port $PORT --workers 2'"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure that the application receives termination signals (like SIGTERM) correctly and to provide a fallback port if the $PORT environment variable is missing, consider using exec and a default value for the port. This also maintains consistency with the implementation in the Dockerfile.

Suggested change
startCommand = "sh -c 'uvicorn app.main:app --host 0.0.0.0 --port $PORT --workers 2'"
startCommand = "sh -c 'exec uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8080} --workers 2'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants