feat(runtime): SIGHUP hot-reload of room bindings (no full restart)

Registering/deregistering a channel via a DB write from a non-main room did not
take effect until a full restart, and restarting from inside an agent turn is
unreliable (the agent is a child of ejclaw.service, so `systemctl restart` kills
it mid-command and it can't be confirmed) — the source of repeated "auto-restart
missing / claimed restart but it didn't happen" failures.

Add a SIGHUP handler that calls runtimeState.reloadRoomBindings(), which re-reads
ONLY room bindings from the DB (cursors/sessions untouched, no re-processing).
`kill -HUP <MainPID>` then makes a registration live instantly with no restart
and no agent death, so it is verifiable in the same turn.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-08-23 19:42:03 +09:00
parent e752524252
commit 9020d2c8c5
3 changed files with 55 additions and 0 deletions

View File

@@ -376,6 +376,17 @@ async function main(): Promise<void> {
};
process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGINT', () => shutdown('SIGINT'));
// SIGHUP hot-reloads room bindings so a channel registered/deregistered via a
// DB write takes effect immediately — no full restart needed. Send it only to
// the main process, e.g. `kill -HUP <MainPID>`, so agent subprocesses are not
// signalled.
process.on('SIGHUP', () => {
try {
runtimeState.reloadRoomBindings();
} catch (err) {
logger.error({ err }, 'Failed to reload room bindings on SIGHUP');
}
});
// Channel callbacks (shared by all channels)
const channelOpts = {