mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 02:26:12 +02:00
Add a terminateActiveTasks option to POST /api/instance/task-drain. When set, the server schedules a stop of every active run one grace period (PAPERCLIP_TASK_DRAIN_TERMINATION_GRACE_PERIOD_SECONDS, default 30s) before the drain's ttlMs expires, so an operator can safely force-stop the process after the drain ends. The option requires a positive ttlMs and needs no new permission: the existing instance-settings authorization floor covers it. A private generation number on the drain state lets a scheduled termination test, at fire time, whether the drain it was armed for is still live — a stop or a later start makes an in-flight timer callback a no-op. Every arm and every outcome writes a durable activity record, with one outcome row per company (including a company with no active run). Co-authored-by: Paperclip <noreply@paperclip.ing>