* Wire `SIGUSR1` to a manual `tick()` so bench scripts can advance the * scheduler with `kill -USR1 ` without a custom RPC. * * Gated on `KIMI_CRON_MANUAL_TICK=1` for two reasons: * * 1. SIGUSR1 only makes sense when auto-tick is off. When the 1s * interval is running,
()
| 531 | * see a bad tick. |
| 532 | */ |
| 533 | private bindSigusr1(): void { |
| 534 | if (process.platform === 'win32') return; |
| 535 | if (process.env['KIMI_CRON_MANUAL_TICK'] !== '1') return; |
| 536 | if (this.sigusr1Handler !== null) return; |
| 537 | const handler: NodeJS.SignalsListener = () => { |
| 538 | try { |
| 539 | this.tick(); |
| 540 | } catch (error) { |
| 541 | if (process.env['KIMI_CRON_DEBUG'] === '1') { |
| 542 | const msg = error instanceof Error ? error.message : String(error); |
| 543 | process.stderr.write( |
| 544 | `[cron/manager] SIGUSR1 tick threw: ${msg}\n`, |
| 545 | ); |
| 546 | } |
| 547 | } |
| 548 | }; |
| 549 | this.sigusr1Handler = handler; |
| 550 | process.on('SIGUSR1', handler); |
| 551 | } |
| 552 | |
| 553 | /** |
| 554 | * Detach the SIGUSR1 listener registered by `bindSigusr1`. Safe to |