SIGTERM already stops go2rtc (the signal handler), but SIGKILL and the OOM killer give the proxy no chance to, and the orphan keeps :1984/:8555 bound and a printer's access code in memory. Two layers, neither needing unsafe or a new dependency: - The watchdog records go2rtc's pid next to its config and, on startup, stops a leftover. It acts only if /proc confirms the pid is still *our* go2rtc - the configured binary on our own `-config` path - so a reused pid or another proxy's go2rtc is never touched; without /proc it does nothing. The pid file is removed when the supervisor goes away. - deploy/continuum-proxy.service, whose KillMode=control-group (written out, with the reason) makes systemd kill the whole cgroup when the proxy dies. Syntax-checked with systemd-analyze only; not run under a real systemd. Tests: the identity check, and a real stand-in process - a leftover is terminated while an unrelated `sleep` survives. Making the identity check always say yes fails both, so they do guard the behaviour. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
39 lines
1.5 KiB
Desktop File
39 lines
1.5 KiB
Desktop File
# Continuum proxy as a systemd service - the template for a Proxy Box or a
|
|
# Linux PC install. Adjust the paths; create the `continuum` user and put the
|
|
# settings it reads (continuum.toml, or the signed bundle on a Box) under
|
|
# /var/lib/continuum.
|
|
#
|
|
# Not exercised under a real systemd yet: this container's init is not
|
|
# systemd, so only `systemd-analyze verify` has been run against it.
|
|
[Unit]
|
|
Description=Continuum proxy (printer gateway)
|
|
Wants=network-online.target
|
|
After=network-online.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=continuum
|
|
# The proxy's relative defaults (./go2rtc.yaml, ./printers.toml, the go2rtc
|
|
# pid file) resolve here, and StateDirectory creates it owned by the user.
|
|
StateDirectory=continuum
|
|
WorkingDirectory=/var/lib/continuum
|
|
ExecStart=/usr/local/bin/continuum-proxy
|
|
|
|
# Always, including a clean exit: installing a new config from a pendrive
|
|
# deliberately ends the process and relies on this to start it on the new
|
|
# settings (src/main.rs, config_import).
|
|
Restart=always
|
|
RestartSec=2
|
|
|
|
# Do not change this to `process` or `none`. go2rtc is the proxy's child, so
|
|
# it lives in this unit's cgroup, and this is what makes systemd kill it
|
|
# whenever the proxy goes - including SIGKILL and the OOM killer, which give
|
|
# the proxy no chance to stop it itself. It is systemd's default; it is
|
|
# written out so nobody weakens it by accident. An orphaned go2rtc keeps
|
|
# :1984/:8555 bound and a printer's access code in memory.
|
|
KillMode=control-group
|
|
TimeoutStopSec=10
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|