The reference plugin — deliberately the smallest thing that is still a real plugin, and what EXTRACTING-A-PLUGIN.md sends people to read. It leaves the platform tree with music and offscale, so that `plugins/` in the platform repository holds documentation and nothing else. That is the point of the move: a directory that contains both tracked source and untracked installs is one where "is this mine or is this installed" has no answer you can see. Same extraction as the two before it: source only, no history. The platform's history still holds every commit that shaped this. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
// 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 permission (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'));
|