interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / infra / spark / interplane-forged.service
| 1 | # INTERPLANE Forge web server (forged) on 127.0.0.1:18480, always on. Install: infra/DEPLOY.md "Service". |
| 2 | # ExecStart is forged-service.sh's own supervisor (_loop), in the foreground, under env -i with only the |
| 3 | # settings below: it takes 127.0.0.1:18480 through forged-listen, holds it for its whole life, and |
| 4 | # restarts forged in the sandbox (FORGED_SANDBOX=on, FORGED_NETNS=on: private network namespace and the |
| 5 | # socket filter). systemd restarts the supervisor. forged-service.sh start|stop|restart|status act on this |
| 6 | # unit when it runs the same FORGE_DATA. |
| 7 | # A deploy installs a reviewed build as a directory (out/forged, out/forged-listen, out/public-read, |
| 8 | # out/forged-seccomp.bpf, infra/spark/) and points FORGED_DIR at it in a host drop-in, |
| 9 | # ~/.config/systemd/user/interplane-forged.service.d/build.conf: |
| 10 | # [Service] |
| 11 | # Environment=FORGED_DIR=%h/.local/lib/interplane-forge/<commit> |
| 12 | [Unit] |
| 13 | Description=INTERPLANE Forge forged on 127.0.0.1:18480 (sandboxed, no network; supervisor holds the port) |
| 14 | # Restart forever: a start that cannot take the port (forged-listen exit 3) retries with backoff. |
| 15 | StartLimitIntervalSec=0 |
| 16 | |
| 17 | [Service] |
| 18 | Type=simple |
| 19 | Environment=FORGED_DIR=%h/.local/lib/interplane-forge/current |
| 20 | Environment=FORGE_DATA=%h/forge-data FORGED_PUBLIC_DIR=%h/forge-public FORGED_COUNTS_STATE=%h/forge-counts-state |
| 21 | ExecStart=/usr/bin/env -i HOME=%h PATH=/usr/bin:/bin FORGED_BIN=${FORGED_DIR}/out/forged FORGE_DATA=${FORGE_DATA} FORGED_PUBLIC_DIR=${FORGED_PUBLIC_DIR} FORGED_COUNTS_STATE=${FORGED_COUNTS_STATE} FORGED_COUNTS_INTERVAL=1800 FORGED_CPUS=4,5 FORGED_SANDBOX=on FORGED_NETNS=on /usr/bin/bash ${FORGED_DIR}/infra/spark/forged-service.sh _loop |
| 22 | # Stop: SIGTERM to the supervisor (its trap stops forged), then whatever is left of the unit. |
| 23 | KillMode=mixed |
| 24 | TimeoutStopSec=30 |
| 25 | # The supervisor restarts forged itself and keeps the port; systemd only restarts a supervisor that |
| 26 | # died. Every process of the unit dies with it (KillMode=mixed) before the restart is scheduled, and |
| 27 | # the listener has SO_REUSEADDR, so the port is free at once: no delay is needed for the port. |
| 28 | # The delay only bounds a start that fails at once (port held by another process, a broken build): |
| 29 | # one attempt per second, two log lines each, never giving up. No RestartSteps: its backoff counts |
| 30 | # every restart in the unit's life, not only recent ones (measured on systemd 255: 3 s runs still |
| 31 | # stepped to the maximum delay), so after a few deaths over weeks every restart would wait the most. |
| 32 | Restart=always |
| 33 | RestartSec=1s |
| 34 | |
| 35 | [Install] |
| 36 | WantedBy=default.target |