steam-backlog-enforcer/steam-backlog-enforcer.service
Krzysztof kuhy Rudnicki a5abb94d85 Keep Steam Runtime's logger out of the journal
Steam's srt-logger runs inside steam-backlog-enforcer.service's cgroup
and mirrors Steam's console into journald on its own — the DEVNULL
stderr the spawn already uses does not reach it, and the env carried
SRT_LOG_TO_JOURNAL=0, which is not the variable it reads. One boot on
2026-09-12 wrote 481k "joystick FFB effect status" lines (99% of the
journal) and evicted two weeks of history from a 300M journal, along
with the evidence for that night's curfew failure.

- desktop_env_args(): SRT_LOGGER_USE_JOURNAL=0, the variable srt-logger
  actually honours. Steam keeps its own logs/console-linux.txt.
- Unit: LogFilterPatterns for the two known flood patterns plus a
  per-unit rate limit, so a future Steam that ignores the variable still
  cannot take the journal with it.

The unit file is deployed and daemon-reloaded; the running service is
not restarted, because Steam is its child and a restart would kill a
live game. The env fix takes effect on the next enforcer start.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015mLnUeoJ3mUwGRTowTUH6d
2026-09-13 10:51:50 +02:00

40 lines
1.7 KiB
Desktop File

[Unit]
Description=Steam Backlog Enforcer
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=/opt/steam-backlog-enforcer
ExecStart=/usr/bin/python3 -m steam_backlog_enforcer.main enforce
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1
Environment=PYTHONPATH=/opt/steam-backlog-enforcer
Environment=HOME=/home/kuhy
Environment=STEAM_ENFORCER_DESKTOP_USER=__DESKTOP_USER__
Environment=DISPLAY=:0
# Hardening: enforcer must not be easily killed.
OOMScoreAdjust=-900
# Journal backstop. Steam's srt-logger runs in this unit's cgroup and mirrors
# Steam's console into journald; 2026-09-12 it wrote 481k "joystick FFB"
# lines in one boot (99% of the journal) and evicted two weeks of history.
# SRT_LOGGER_USE_JOURNAL=0 in the spawn env is the fix at source; these two
# make sure a future Steam that ignores it still cannot flood the journal.
LogFilterPatterns=~Failed to get joystick[0-9]+ FFB effect status
LogFilterPatterns=~FFBInterface
LogRateLimitIntervalSec=1min
LogRateLimitBurst=2000
#
# DO NOT ADD PrivateMounts=, PrivateTmp=, ProtectSystem= OR ProtectHome= HERE.
# The daily gaming budget enforces its cutoff by bind-mounting a refusal stub
# over /usr/bin/steam and the other launcher entry points. Any of those
# directives gives this service a private mount namespace, so those mounts stay
# invisible to the rest of the system: the launchers keep working while the
# counter keeps running, and the block silently becomes a no-op. That failure
# mode is invisible from the outside, which is why it is spelled out here.
# _playtime_block.mounts_are_visible() logs an error if it ever happens.
[Install]
WantedBy=multi-user.target