openvibers/openvibe.host Commits
Listen on the socket systemd hands over, so a restart never answers 502 (#214)
Changes
@@@ -9,7 +9,10 @@ async function main() {const { app, ctx } = await createApp();const { config } = ctx;--const server = app.listen(config.port, config.host, () => {++// Socket activation (2026-10-31): systemd's .socket unit holds the listener across restarts, so a deploy++// queues requests in the kernel instead of answering 502. Without the socket unit, the usual listen.++const socketActivated = process.env.LISTEN_FDS === '1' && Number(process.env.LISTEN_PID) === process.pid;++const server = app.listen(...(socketActivated ? [{ fd: 3 }] : [config.port, config.host]), () => {console.log(`[Host] ${config.nodeEnv} on http://${config.host}:${config.port} → catalog ${config.baseUrl} (db ${config.db.url ? 'PostgreSQL' : 'embedded PGlite'})`);console.log(`[Host] events relay ${ctx.outbox.enabled ? `on → ${config.events.url}` : 'off (events wait in event_outbox)'}; worker ${config.worker.enabled ? 'on' : 'off'}`);});
@@ -9,7 +9,10 @@ async function main() {
@@ -9,7 +9,10 @@ async function main() {
const { app, ctx } = await createApp();
const { app, ctx } = await createApp();
const { config } = ctx;
const { config } = ctx;
-const server = app.listen(config.port, config.host, () => {
+// Socket activation (2026-10-31): systemd's .socket unit holds the listener across restarts, so a deploy
+// queues requests in the kernel instead of answering 502. Without the socket unit, the usual listen.
+const socketActivated = process.env.LISTEN_FDS === '1' && Number(process.env.LISTEN_PID) === process.pid;
+const server = app.listen(...(socketActivated ? [{ fd: 3 }] : [config.port, config.host]), () => {
console.log(`[Host] ${config.nodeEnv} on http://${config.host}:${config.port} → catalog ${config.baseUrl} (db ${config.db.url ? 'PostgreSQL' : 'embedded PGlite'})`);
console.log(`[Host] ${config.nodeEnv} on http://${config.host}:${config.port} → catalog ${config.baseUrl} (db ${config.db.url ? 'PostgreSQL' : 'embedded PGlite'})`);
console.log(`[Host] events relay ${ctx.outbox.enabled ? `on → ${config.events.url}` : 'off (events wait in event_outbox)'}; worker ${config.worker.enabled ? 'on' : 'off'}`);
console.log(`[Host] events relay ${ctx.outbox.enabled ? `on → ${config.events.url}` : 'off (events wait in event_outbox)'}; worker ${config.worker.enabled ? 'on' : 'off'}`);
});
});