forked from wrenn/wrenn
Replaces the hardcoded CP_HOST_AGENT_ADDR single-agent setup with a DB-driven registration system supporting multiple host agents (BYOC). Key changes: - Host agents register via one-time token, receive a 7-day JWT + 60-day refresh token; heartbeat loop auto-refreshes on 401/403 and pauses all sandboxes if refresh fails - HostClientPool: lazy Connect RPC client cache keyed by host ID, replacing the single static agent client throughout the API and service layers - RoundRobinScheduler: picks an online host for each new sandbox via ListActiveHosts; extensible for future scheduling strategies - HostMonitor (replaces Reconciler): passive heartbeat staleness check marks hosts unreachable and sandboxes missing after 90s; active reconciliation per online host restores missing-but-alive sandboxes and stops orphans - Graceful host delete: returns 409 with affected sandbox list without ?force=true; force-delete destroys sandboxes then evicts pool client - Snapshot delete broadcasts to all online hosts (templates have no host_id) - sandbox.Manager.PauseAll: pauses all running VMs on CP connectivity loss - New migration: host_refresh_tokens table with token rotation (issue-then- revoke ordering to prevent lockout on mid-rotation crash) - New sandbox status 'missing' (reversible, unlike 'stopped') and host status 'unreachable'; both reflected in OpenAPI spec - Fix: refresh token auth failure now returns 401 (was 400 via generic 'invalid' substring match in serviceErrToHTTP)
35 lines
760 B
Plaintext
35 lines
760 B
Plaintext
# Database
|
|
DATABASE_URL=postgres://wrenn:wrenn@localhost:5432/wrenn?sslmode=disable
|
|
|
|
# Redis
|
|
REDIS_URL=redis://localhost:6379/0
|
|
|
|
# Control Plane
|
|
CP_LISTEN_ADDR=:8000
|
|
|
|
# Host Agent
|
|
AGENT_LISTEN_ADDR=:50051
|
|
AGENT_FILES_ROOTDIR=/var/lib/wrenn
|
|
AGENT_HOST_INTERFACE=eth0
|
|
AGENT_CP_URL=http://localhost:8000
|
|
|
|
# Lago (billing — external service)
|
|
LAGO_API_URL=http://localhost:3000
|
|
LAGO_API_KEY=
|
|
|
|
# Object Storage (hibernate snapshots — Hetzner Object Storage, S3-compatible)
|
|
S3_BUCKET=wrenn-snapshots
|
|
S3_REGION=fsn1
|
|
S3_ENDPOINT=https://fsn1.your-objectstorage.com
|
|
AWS_ACCESS_KEY_ID=
|
|
AWS_SECRET_ACCESS_KEY=
|
|
|
|
# Auth
|
|
JWT_SECRET=
|
|
|
|
# OAuth
|
|
OAUTH_GITHUB_CLIENT_ID=
|
|
OAUTH_GITHUB_CLIENT_SECRET=
|
|
OAUTH_REDIRECT_URL=https://app.wrenn.dev
|
|
CP_PUBLIC_URL=https://api.wrenn.dev
|