Skip to content

Commit ed79cbf

Browse files
Fix Railpack/Railway start detection
Add root app.py and Procfile for uvicorn start; default bind to 0.0.0.0 and use platform PORT when provided. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent bfd721e commit ed79cbf

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Procfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web: uvicorn local_nexus_controller.main:app --host 0.0.0.0 --port $PORT
2+

app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
Railpack/Railway-friendly entrypoint.
3+
4+
Railpack will auto-start FastAPI apps if it can find an `app` object in
5+
`app.py` or `main.py` at the repository root. This file provides that.
6+
"""
7+
8+
from local_nexus_controller.main import app # noqa: F401
9+

local_nexus_controller/settings.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ def load_settings() -> Settings:
3535
db_path_raw = os.getenv("LOCAL_NEXUS_DB_PATH", "data/local_nexus.db")
3636
db_path = (project_root / db_path_raw).resolve() if not Path(db_path_raw).is_absolute() else Path(db_path_raw)
3737

38-
host = os.getenv("LOCAL_NEXUS_HOST", "127.0.0.1")
39-
port = _to_int(os.getenv("LOCAL_NEXUS_PORT"), 5010)
38+
# Deployment-friendly defaults:
39+
# - Platforms like Railway provide PORT; services must bind 0.0.0.0:$PORT.
40+
platform_port = os.getenv("PORT")
41+
host_default = "0.0.0.0" if platform_port else "127.0.0.1"
42+
host = os.getenv("LOCAL_NEXUS_HOST", host_default)
43+
44+
port_raw = os.getenv("LOCAL_NEXUS_PORT") or platform_port
45+
port = _to_int(port_raw, 5010)
4046
token = os.getenv("LOCAL_NEXUS_TOKEN") or None
4147

4248
port_range_start = _to_int(os.getenv("LOCAL_NEXUS_PORT_RANGE_START"), 3000)

0 commit comments

Comments
 (0)