openvibers/openvibe.meme Commits

Listen on the socket systemd hands over, so a restart never answers 502 (#18)

OP OpenVibers committed 13 days ago · 88e6435f31 · 1 file, +4 −1

When the service is socket-activated (LISTEN_FDS=1 for this process), it listens on fd 3, the listener a
systemd .socket unit holds across restarts: requests that arrive during a deploy wait in the kernel's accept
queue and are served by the new process. Without the socket unit it listens on its port as before. The same
three lines Network, Media, Chat and Live use. 2026-10-31: a Codes deploy gave the owner a Cloudflare 502.

Changes

ddiff --git a/server/index.js b/server/index.js
iindex 100916d..e6f83f7 100644
---- a/server/index.js
++++ b/server/index.js
@@@ -32,7 +32,10 @@ async function start() {
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(`[OpenVibe.Meme] ${config.nodeEnv} on http://${config.host}:${config.port} → ${config.baseUrl} (db ${ctx.s.db.store})`);
// Warm the Network signing key immediately: a service nobody has signed in to yet must not read degraded
// only because the first JWKS fetch had not happened.