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

+2
View File
@@ -30,6 +30,8 @@ NVD_API_KEY=
# Agent
AGENT_PORT=3001
# Port of the separate webhook listener (Git push / PR events).
WEBHOOK_PORT=3002
# Scans (and PR reviews) running at once across all tenants; each is a clone
# plus semgrep and syft. Requests for a target already being scanned coalesce
# into one follow-up instead of running in parallel.