Make production listener configurable
This commit is contained in:
@@ -9,6 +9,8 @@ User=website-engine
|
|||||||
Group=website-engine
|
Group=website-engine
|
||||||
WorkingDirectory=/opt/website-engine-control-plane
|
WorkingDirectory=/opt/website-engine-control-plane
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
|
Environment=HOST=127.0.0.1
|
||||||
|
Environment=PORT=3000
|
||||||
Environment=LABYRICORN_BUILD_ROOT=/var/lib/website-engine/builds
|
Environment=LABYRICORN_BUILD_ROOT=/var/lib/website-engine/builds
|
||||||
ExecStart=/usr/bin/node /opt/website-engine-control-plane/dist/server.cjs
|
ExecStart=/usr/bin/node /opt/website-engine-control-plane/dist/server.cjs
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|||||||
@@ -12,7 +12,12 @@ const execAsync = promisify(exec);
|
|||||||
|
|
||||||
async function startServer() {
|
async function startServer() {
|
||||||
const app = express();
|
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());
|
app.use(express.json());
|
||||||
|
|
||||||
@@ -756,8 +761,8 @@ async function startServer() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.listen(PORT, "0.0.0.0", () => {
|
app.listen(port, host, () => {
|
||||||
console.log(`Labyricorn Control Plane running on http://0.0.0.0:${PORT}`);
|
console.log(`Labyricorn Control Plane running on http://${host}:${port}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user