Backend:
- Session.last_subscriber_left_at: monotonic timestamp set when last SSE subscriber
leaves, cleared when a new one arrives
- Session.subscriber_count(): replaces len(_subscribers) access from outside the model
- session_store._reaper_loop(): kills sessions with no subscribers for >SESSION_IDLE_TTL_S
(default 90s); runs every TTL/2 seconds via asyncio.create_task at startup
- session_store._reaper_loop_once(): single-cycle variant for deterministic tests
- app/main.py lifespan: starts reaper on startup, cancels it cleanly on shutdown
- config.py: SESSION_IDLE_TTL_S setting (90s default, overridable per-env)
Frontend:
- useWakeLock.ts: Screen Wake Lock API wrapper; acquires on connect, releases on
disconnect; degrades silently when unsupported (battery saver, iOS Safari)
- useToneStream.ts: visibilitychange handler — on hidden: closes EventSource without
ending backend session (grace window stays open); on visible: GET /session/{id}
liveness check, reconnects SSE + re-acquires wake lock if alive, sets expired=true
and calls store.reset() if reaped
- ComposeBar.vue: surfaces expired state with calm 'Session timed out' notice
(not an error — expected behaviour on long screen-off)
Tests:
- test_reaper.py: 7 tests covering subscriber idle tracking, reaper eligibility
(kills idle, spares active subscriber, spares within-TTL)
60 lines
1.9 KiB
YAML
60 lines
1.9 KiB
YAML
# compose.cloud.yml — Cloud managed instance
|
|
#
|
|
# Project: linnet-cloud (docker compose -f compose.cloud.yml -p linnet-cloud ...)
|
|
# Web: http://127.0.0.1:8527 → menagerie.circuitforge.tech/linnet (via Caddy + JWT)
|
|
# API: internal only on linnet-cloud-net (nginx proxies /session/ → linnet-api:8522)
|
|
#
|
|
# Requires in .env:
|
|
# CLOUD_MODE=true
|
|
# LINNET_LICENSE_KEY=CFG-LNNT-... (or per-request key via API)
|
|
# HEIMDALL_URL=https://license.circuitforge.tech
|
|
# DIRECTUS_JWT_SECRET=... (Caddy injects X-CF-Session from cf_session cookie)
|
|
# HF_TOKEN=... (needed for real cf-voice inference; omit for mock)
|
|
# CF_VOICE_MOCK=0 (set to 1 during staged rollout)
|
|
|
|
services:
|
|
linnet-api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
args:
|
|
GIT_TOKEN: ${GIT_TOKEN:-}
|
|
restart: unless-stopped
|
|
env_file: .env
|
|
environment:
|
|
CLOUD_MODE: "true"
|
|
LINNET_PORT: "8522"
|
|
LINNET_FRONTEND_PORT: "8527"
|
|
LINNET_BASE_URL: "https://menagerie.circuitforge.tech/linnet"
|
|
CLOUD_DATA_ROOT: /devl/linnet-cloud-data
|
|
CF_ORCH_URL: http://host.docker.internal:7700
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
volumes:
|
|
- /devl/linnet-cloud-data:/devl/linnet-cloud-data
|
|
- ${HOME}/.config/circuitforge:/root/.config/circuitforge:ro
|
|
# Live-reload app code without rebuilding during active dev
|
|
- ./app:/app/app:ro
|
|
networks:
|
|
- linnet-cloud-net
|
|
|
|
linnet-web:
|
|
build:
|
|
context: .
|
|
dockerfile: docker/web/Dockerfile
|
|
args:
|
|
VITE_BASE_URL: /linnet/
|
|
VITE_API_BASE: /linnet
|
|
restart: unless-stopped
|
|
ports:
|
|
- "8527:80"
|
|
volumes:
|
|
- ./docker/web/nginx.cloud.conf:/etc/nginx/conf.d/default.conf:ro
|
|
networks:
|
|
- linnet-cloud-net
|
|
depends_on:
|
|
- linnet-api
|
|
|
|
networks:
|
|
linnet-cloud-net:
|
|
driver: bridge
|