[Unit] Description=BubbleCam camera capture supervisor (%i) After=bubblecam-rtc-sync.service local-fs.target Wants=bubblecam-rtc-sync.service # Rate limiting belongs in [Unit], not [Service] -- systemd ignores these # keys entirely if they appear under [Service] (it logs "Unknown key"), # which silently disables the restart cap. StartLimitIntervalSec=300 StartLimitBurst=10 [Service] Type=simple ExecStart=/opt/bubblecam/bin/capture_supervisor.py %i # The target /dev/videoN node may not exist yet at the moment this unit # starts (USB enumeration timing on the OTG port is not instantaneous, and # a generic template can't bind to a specific per-instance systemd device # unit). Rather than a blind sleep, capture_supervisor.py lets ffmpeg fail # fast if the device isn't there yet, and this unit just retries until it # is -- self-correcting within a few seconds in practice. Restart=on-failure RestartSec=5 User=root Nice=-5 IOSchedulingClass=best-effort IOSchedulingPriority=2 [Install] WantedBy=multi-user.target