feat(platform): graceful shutdown and restart recovery (#259)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 5m53s

A redeploy used to cut every request mid-flight and leave the scans it
killed marked `running` forever.

- The agent API, webhook and MCP servers stop accepting connections on
  SIGTERM/Ctrl+C, let in-flight requests finish, and drop what is still
  open after 8 s (under Docker's 10 s stop timeout).
  `compliance_core::shutdown` holds the shared signal/drain helper.
- At startup, before anything can start a run, runs the previous process
  left open are closed in every tenant. Scan runs get a new `interrupted`
  status. DAST runs, pentest sessions (running or paused: pause state lives
  in memory), and graph/embedding builds become `failed` with the message
  "interrupted by agent restart".
- `JobQueue::sweep_expired` now runs every 60 s across tenants (at most 3
  lease attempts per job).
- The webhook port comes from `WEBHOOK_PORT` (default 3002).

Assumes one agent per environment, as in every Orca deployment today.

Closes #65, closes #68.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5 committed 2026-09-21 17:26:22 +02:00
1 parent bc4553d576
commit e4f7fb540b
15 files changed
+788 -13

No files matched your search

+1
View File
@@ -52,6 +52,7 @@ Each scan progresses through these statuses:
| **Running** | Currently executing scan phases |
| **Completed** | All phases finished successfully |
| **Failed** | Stopped due to an error |
| **Interrupted** | The scanner was restarted (for example by an update) while the scan was running. Nothing in your code caused it; start the scan again. |
You can monitor scan progress on the Overview page, which shows the most recent scan runs across all repositories, including the current phase, finding count, and duration.