Fix Railway deployment config and health endpoint

This commit is contained in:
Alexa Amundson
2025-11-22 00:29:21 -06:00
parent bb4f0e9d82
commit d991ff978a
7 changed files with 18 additions and 15 deletions

View File

@@ -1,11 +1,15 @@
[phases.setup] [phases.setup]
nixPkgs = ["python312"] nixPkgs = ["nodejs_20"]
[phases.install] [phases.install]
cmds = [ cmds = [
"python -m pip install --upgrade pip", "npm ci",
"pip install -r requirements.txt", ]
[phases.build]
cmds = [
"npm run build",
] ]
[start] [start]
cmd = 'uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8080}' cmd = "npm run start"

View File

@@ -2,10 +2,10 @@
"$schema": "https://railway.com/railway.schema.json", "$schema": "https://railway.com/railway.schema.json",
"build": { "build": {
"builder": "NIXPACKS", "builder": "NIXPACKS",
"buildCommand": "pip install -r requirements.txt" "buildCommand": "npm ci && npm run build"
}, },
"deploy": { "deploy": {
"startCommand": "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8080}", "startCommand": "npm run start",
"healthcheckPath": "/health", "healthcheckPath": "/health",
"healthcheckTimeout": 100, "healthcheckTimeout": 100,
"restartPolicyType": "always" "restartPolicyType": "always"

View File

@@ -9,6 +9,7 @@ const parsePort = (value: string | undefined, fallback: number): number => {
export const env = { export const env = {
PORT: parsePort(process.env.PORT, 8080), PORT: parsePort(process.env.PORT, 8080),
HOST: process.env.HOST || "0.0.0.0",
CORE_BASE_URL: process.env.CORE_BASE_URL || "http://localhost:3001", CORE_BASE_URL: process.env.CORE_BASE_URL || "http://localhost:3001",
AGENTS_BASE_URL: process.env.AGENTS_BASE_URL || "http://localhost:3002", AGENTS_BASE_URL: process.env.AGENTS_BASE_URL || "http://localhost:3002",
OPERATOR_BASE_URL: process.env.OPERATOR_BASE_URL || "http://localhost:3003", OPERATOR_BASE_URL: process.env.OPERATOR_BASE_URL || "http://localhost:3003",

View File

@@ -30,8 +30,8 @@ app.use((err: Error, _req: express.Request, res: express.Response, _next: expres
}); });
if (process.env.NODE_ENV !== "test") { if (process.env.NODE_ENV !== "test") {
app.listen(env.PORT, () => { app.listen(env.PORT, env.HOST, () => {
console.log(`Gateway listening on port ${env.PORT}`); console.log(`Gateway listening on ${env.HOST}:${env.PORT}`);
}); });
} }

View File

@@ -4,10 +4,9 @@ import { SERVICE_ID } from "../config/serviceConfig";
const router = Router(); const router = Router();
router.get("/health", (req: Request, res: Response) => { router.get("/health", (req: Request, res: Response) => {
res.json({ res.status(200).json({
ok: true, status: "ok",
service: SERVICE_ID, service: SERVICE_ID,
ts: new Date().toISOString(),
}); });
}); });

View File

@@ -4,10 +4,9 @@ import { SERVICE_ID } from "../../config/serviceConfig";
const router = Router(); const router = Router();
router.get("/health", (req: Request, res: Response) => { router.get("/health", (req: Request, res: Response) => {
res.json({ res.status(200).json({
ok: true, status: "ok",
service: SERVICE_ID, service: SERVICE_ID,
ts: new Date().toISOString(),
}); });
}); });

View File

@@ -6,7 +6,7 @@ describe("GET /health", () => {
const response = await request(app).get("/health"); const response = await request(app).get("/health");
expect(response.status).toBe(200); expect(response.status).toBe(200);
expect(response.body).toHaveProperty("ok", true); expect(response.body).toHaveProperty("status", "ok");
expect(response.body).toHaveProperty("service", "api"); expect(response.body).toHaveProperty("service", "api");
}); });
}); });