Make production listener configurable

This commit is contained in:
2026-07-23 13:47:39 -07:00
parent bd5538e778
commit 208e2153e3
2 changed files with 10 additions and 3 deletions
+2
View File
@@ -9,6 +9,8 @@ User=website-engine
Group=website-engine
WorkingDirectory=/opt/website-engine-control-plane
Environment=NODE_ENV=production
Environment=HOST=127.0.0.1
Environment=PORT=3000
Environment=LABYRICORN_BUILD_ROOT=/var/lib/website-engine/builds
ExecStart=/usr/bin/node /opt/website-engine-control-plane/dist/server.cjs
Restart=on-failure
+8 -3
View File
@@ -12,7 +12,12 @@ const execAsync = promisify(exec);
async function startServer() {
const app = express();
const PORT = 3000;
const port = Number.parseInt(process.env.PORT ?? "3000", 10);
const host = process.env.HOST ?? "0.0.0.0";
if (!Number.isInteger(port) || port < 1 || port > 65535) {
throw new Error(`Invalid PORT value: ${process.env.PORT}`);
}
app.use(express.json());
@@ -756,8 +761,8 @@ async function startServer() {
});
}
app.listen(PORT, "0.0.0.0", () => {
console.log(`Labyricorn Control Plane running on http://0.0.0.0:${PORT}`);
app.listen(port, host, () => {
console.log(`Labyricorn Control Plane running on http://${host}:${port}`);
});
}