Report-only unit, off by default, not bound to flysim, SCHED_IDLE on the page and encoder CPUs, stays stopped after a divergence (exit 3). fly-shadow-run start|stop|status|check installs the flysim trace drop-in, restarts flysim once and reads the verdict. Deploy, build and packaging ship fly-shadow and fly-session; lint holds the unit to its rules; the runbook has a Shadow run section.
60 lines
3 KiB
Desktop File
60 lines
3 KiB
Desktop File
# infra/units/flyshadow.service — pushed to /etc/systemd/system/flyshadow.service.
|
|
#
|
|
# SHADOW-01 (docs/design/session-framework/legacy-gameboy-v1.md section 18): the
|
|
# session runtime run beside the live fly. REPORT-ONLY: it presses no button,
|
|
# serves no port, and only READS flysim's stores and trace; it writes nothing
|
|
# but /srv/fly/shadow (verdict.json, divergence.json, its spool) and its
|
|
# runtime directory. DISABLED BY DEFAULT: in no target's Wants=/Requires=,
|
|
# not in 07-enable.sh. `fly-shadow-run start` (infra/bin) starts it, turns
|
|
# flysim's trace on and restarts flysim once so the shadow follows a process
|
|
# from its first frame; `fly-shadow-run stop` undoes both.
|
|
#
|
|
# Deliberately NOT bound to flysim (no Requires=/BindsTo=/PartOf=): every
|
|
# flysim restart (the unstick rule, the watchdog, fly-loop-recover, a
|
|
# milestone reset) is a new trace file the shadow follows on its own, so the
|
|
# shadow must outlive them. It stops itself on the first divergence with exit
|
|
# status 3 and a `diverged` verdict; RestartPreventExitStatus keeps it
|
|
# stopped so the verdict stays for the coordinator to read.
|
|
#
|
|
# Resources (the SHADOW-01 report, "resource plan"): a second whole brain,
|
|
# about the live fly's own CPU per frame. It must never take a cycle the live
|
|
# fly, the page or the encoder wants, so it runs SCHED_IDLE (it only gets CPU
|
|
# nobody else is using), off flysim's cpuset (05-deploy.sh writes
|
|
# AllowedCPUs= for it from the page and encoder groups), and it pauses for a
|
|
# minute whenever flysim's own fly_lag_seconds grows (the live loop fell more
|
|
# than a second behind; `--max-live-lag-seconds`). It is lag-tolerant: the
|
|
# trace and the spool are on disk, so running behind real time only delays
|
|
# the verdict (the 512 MiB spool covers about 15 minutes of lag for hot saves).
|
|
[Unit]
|
|
Description=flyshadow: the session runtime shadowing the live fly (SHADOW-01, report only)
|
|
After=flysim.service
|
|
# A release that predates SHADOW-01 has no binary; stay cleanly inactive.
|
|
ConditionPathExists=/opt/fly/current/fly-shadow
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=fly
|
|
# The live service's configuration, read the way flysim reads it: the
|
|
# cartridge, the dataset, the macro mode, the speed. The store paths and the
|
|
# metrics listener are flysim.service's own Environment= lines, repeated.
|
|
EnvironmentFile=/etc/fly/fly.env
|
|
Environment=FLY_STATE_HOT=/run/fly/state
|
|
Environment=FLY_STATE=/srv/fly/state
|
|
Environment=FLY_METRICS_ADDR=0.0.0.0:9101
|
|
# What flysim writes with the shadow's drop-in (fly-shadow-run), and where the
|
|
# verdict goes. The session's sockets and artifacts live on tmpfs.
|
|
Environment=FLY_TRACE_DIR=/srv/fly/shadow/trace
|
|
Environment=FLY_SHADOW_DIR=/srv/fly/shadow
|
|
Environment=FLY_SHADOW_WORK=/run/fly-shadow
|
|
RuntimeDirectory=fly-shadow
|
|
# The shadow agent's sweep threads (the report's measurements).
|
|
Environment=FLY_SHADOW_THREADS=2
|
|
ExecStart=/opt/fly/current/fly-shadow run
|
|
Restart=on-failure
|
|
RestartSec=10
|
|
RestartPreventExitStatus=3
|
|
CPUSchedulingPolicy=idle
|
|
Nice=19
|
|
CPUWeight=1
|
|
IOSchedulingClass=idle
|
|
MemoryMax=3G
|