// The reference sidecar: a long-lived process PM2 supervises. // // A sidecar is a PEER of `officer`, never a child — that is why restarting the platform does not disturb // it, and it is the property that makes install-without-restart possible on the platform side too. // // A real one binds a loopback port and registers over `/api/sidecar/register` so the platform can reach // it by capability (see `servers/sidecar/connect.ts`). This one does neither, on purpose: it exists to // prove that a plugin's process is written into the ecosystem file, started, stopped and deleted by the // installer, and adding a socket here would test Bun rather than that. const name = 'officer-example'; console.log(`[${name}] started (pid ${process.pid})`); // Something to see in `pm2 logs officer-example`, and a reason for the process to still be alive. const beat = setInterval(() => console.log(`[${name}] alive`), 60_000); const shutdown = (signal: string) => { console.log(`[${name}] ${signal} — exiting`); clearInterval(beat); process.exit(0); }; process.on('SIGTERM', () => shutdown('SIGTERM')); process.on('SIGINT', () => shutdown('SIGINT'));