Files
LEDMatrix/systemd/ledmatrix-web.service
ChuckandClaude Opus 5.5 ed0753c1ca perf: cheap per-frame and per-fetch savings (#725)
Six small savings with no behaviour change: the odds fetch no longer pretty-prints every response for a debug line; the scroll integer-slice path drops a redundant full-frame np.ascontiguousarray; ledmatrix-web.service gets MALLOC_ARENA_MAX=2 like the display unit; core ESPN responses are parsed via response_json (orjson when installed); and the scroll frame stats go to INFO only for degraded windows plus a 5-minute heartbeat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 14:26:03 -04:00

43 lines
1.9 KiB
Desktop File

# This is a template. Do not install it directly -- run
# scripts/install/install_web_service.sh (or install_service.sh, which
# renders this same file). Both substitute:
# __PROJECT_ROOT_DIR__ -> the directory the project is installed in
# __USER__ -> the user the web interface runs as
#
# This file is the only description of the unit. It used to be duplicated as
# an inline heredoc in both installers, which drifted apart; src/startup_validator.py
# compares the installed unit against this template, so a second copy means a
# permanent, unclearable drift warning on every boot.
[Unit]
Description=LED Matrix Web Interface Service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=__USER__
WorkingDirectory=__PROJECT_ROOT_DIR__
Environment=USE_THREADING=1
# Cap glibc's malloc arenas, as ledmatrix.service does: each allocating thread
# can get its own arena, up to 8 x CPU count (24 on a 3-core Pi), and a grown
# arena is never handed back to the OS. This threaded Flask process would hold
# that memory the same way. See ledmatrix.service for the measurement.
Environment=MALLOC_ARENA_MAX=2
ExecStart=/usr/bin/python3 __PROJECT_ROOT_DIR__/scripts/utils/start_web_conditionally.py
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=ledmatrix-web
# No CacheDirectory=. /var/cache/ledmatrix is shared with ledmatrix.service,
# which runs as root, and the installers set it up as root:ledmatrix 2775 so
# both services can read what the other writes. CacheDirectory= makes systemd
# re-own that directory and everything in it to this unit's User= and that
# user's primary group whenever the owner differs -- which, for a directory
# root created, is on the first start. That erased the shared group, and from
# then on the web interface could not read a single file the display wrote.
[Install]
WantedBy=multi-user.target