Files
wrenn/.env.example
pptx704 1bb2166537 agent/envd: drive inactivity-pause by real VM work, not just requests
The TTL reaper only saw "last user request" time, so a long-running but
non-interactive job (build, download) was auto-paused mid-run, while a
parked `sleep infinity` could not be distinguished from real work.

Add a guest liveness signal and fold it into the existing LastActiveAt
clock the reaper already uses (reaper logic unchanged):

- envd: extend the 1s sampler to also diff /proc/net/dev and
  /proc/diskstats into net_bps/disk_bps (deltas, core-normalized CPU
  already present); expose GET /activity (atomic reads, no syscalls),
  auth-excluded like /health.
- host agent: StartActivitySampler polls each running sandbox every 5s
  (bounded concurrency) and refreshes its TTL when busy — guest CPU >=
  threshold, or net/disk throughput >= floor. Debounced over 2
  consecutive samples so an isolated idle-noise spike cannot keep a
  sandbox alive.
- proxy: inbound proxy traffic now counts as activity (AcquireProxyConn
  bumps LastActiveAt), so an idle-but-served web server stays up.

Thresholds (CPU 5%, net 16KB/s, disk 32KB/s, interval 5s) are
env-overridable: WRENN_CPU_BUSY_THRESHOLD, WRENN_NET_FLOOR_BPS,
WRENN_DISK_FLOOR_BPS, WRENN_ACTIVITY_SAMPLE_INTERVAL.

Net effect: sleep-infinity and idle terminals still pause; builds,
downloads, and served servers stay alive.
2026-06-21 04:13:03 +06:00

63 lines
2.0 KiB
Plaintext

# Shared (applies to both control plane and host agent)
WRENN_DIR=/var/lib/wrenn
LOG_LEVEL=info
# Database
DATABASE_URL=postgres://wrenn:wrenn@localhost:5432/wrenn?sslmode=disable
# Redis
REDIS_URL=redis://localhost:6379/0
# Control Plane
WRENN_CP_LISTEN_ADDR=:9725
# Host Agent
WRENN_HOST_LISTEN_ADDR=:50051
WRENN_HOST_INTERFACE=eth0
WRENN_CP_URL=http://localhost:9725
WRENN_DEFAULT_ROOTFS_SIZE=5Gi
WRENN_CH_BIN=/usr/local/bin/cloud-hypervisor
# Public domain sandboxes are served under; injected into envd so `envd ports`
# can build {port}-{sandbox_id}.{domain} URLs.
WRENN_PROXY_DOMAIN=wrenn.dev
# Inactivity activity sampler (all optional; shown values are the defaults).
# The host polls each running sandbox's guest liveness and refreshes its
# inactivity TTL when it is doing real work, so a long-running but
# non-interactive job (build, download) is not auto-paused. A sandbox counts
# as busy when guest CPU ≥ threshold, or net/disk throughput ≥ the floor.
# Busy requires the threshold to hold for 2 consecutive samples (debounced),
# so isolated idle-noise spikes do not keep a sandbox alive.
WRENN_ACTIVITY_SAMPLE_INTERVAL=5s
WRENN_CPU_BUSY_THRESHOLD=5.0
WRENN_NET_FLOOR_BPS=16384
WRENN_DISK_FLOOR_BPS=32768
# Auth
JWT_SECRET=
# mTLS — CP→Agent channel
# Generate a self-signed CA with:
# openssl ecparam -genkey -name P-256 -noout -out ca.key
# openssl req -new -x509 -key ca.key -days 3650 -out ca.crt -subj "/CN=wrenn-internal-ca"
# Then set these to the file contents (newlines replaced with \n or use multiline env).
WRENN_CA_CERT=
WRENN_CA_KEY=
# Channels (notification destinations)
# AES-256-GCM key for encrypting channel secrets. Generate with: openssl rand -hex 32
WRENN_ENCRYPTION_KEY=
# OAuth
OAUTH_GITHUB_CLIENT_ID=
OAUTH_GITHUB_CLIENT_SECRET=
OAUTH_REDIRECT_URL=https://app.wrenn.dev
CP_PUBLIC_URL=https://app.wrenn.dev
# SMTP — transactional email (optional; omit SMTP_HOST to disable)
SMTP_HOST=
SMTP_PORT=587
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_FROM_EMAIL=noreply@wrenn.dev