Files
LEDMatrix/systemd
ChuckandClaude Opus 5 e6249dcc7e fix(service): survive corrupt health cache and clean exits
Three independent failure modes that each end with a dark panel and no
automatic recovery.

1. PluginHealthTracker._load_health_state returned the cached value
   verbatim. If that value is not a dict, every caller raises
   AttributeError: 'list' object has no attribute 'get' — during
   DisplayController.__init__, so the process dies before the display
   loop starts. systemd restarts it, the same bad entry is read back
   from disk, and it dies again: an unattended restart loop that
   survives reboots because the cause is persisted. Observed in the
   field with plugin_health:<id> holding an unrelated plugin's list
   payload. Now non-dict entries are discarded with a warning and the
   defaults are rebuilt.

2. ledmatrix.service used Restart=on-failure, so any exit with status 0
   left the unit stopped and the panel dark indefinitely — systemd
   treats it as success and never brings it back. Restart=always.

3. ledmatrix-wifi-monitor.service used StandardOutput=syslog, which
   systemd has marked obsolete; it warns and rewrites it to journal on
   every load.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 19:04:57 -04:00
..

Systemd Service Files

This directory contains systemd service unit files for LEDMatrix services.

Service Files

  • ledmatrix.service - Main LED Matrix display service

    • Runs the display controller (run.py)
    • Starts automatically on boot
    • Runs as root for hardware access
  • ledmatrix-web.service - Web interface service

    • Runs the web interface conditionally based on config
    • Starts automatically on boot if web_display_autostart is enabled
    • Uses scripts/utils/start_web_conditionally.py
  • ledmatrix-wifi-monitor.service - WiFi monitor daemon service

    • Monitors WiFi/Ethernet connectivity
    • Automatically enables/disables access point mode
    • Uses scripts/utils/wifi_monitor_daemon.py

Installation

These service files are installed by the installation scripts in scripts/install/:

  • install_service.sh installs ledmatrix.service
  • install_web_service.sh installs ledmatrix-web.service
  • install_wifi_monitor.sh installs ledmatrix-wifi-monitor.service

Manual Installation

Important: the unit files in this directory contain __PROJECT_ROOT_DIR__ placeholders that the install scripts replace with the actual project directory at install time. Do not copy them directly to /etc/systemd/system/ — the service will fail to start with WorkingDirectory=__PROJECT_ROOT_DIR__ errors.

Always install via the helper script:

sudo ./scripts/install/install_service.sh

If you really need to do it by hand, substitute the placeholder first:

PROJECT_ROOT="$(pwd)"
sed "s|__PROJECT_ROOT_DIR__|$PROJECT_ROOT|g" systemd/ledmatrix.service \
  | sudo tee /etc/systemd/system/ledmatrix.service > /dev/null
sudo systemctl daemon-reload
sudo systemctl enable ledmatrix.service
sudo systemctl start ledmatrix.service

Service Management

# Check status
sudo systemctl status ledmatrix.service

# Start/stop/restart
sudo systemctl start ledmatrix.service
sudo systemctl stop ledmatrix.service
sudo systemctl restart ledmatrix.service

# Enable/disable autostart
sudo systemctl enable ledmatrix.service
sudo systemctl disable ledmatrix.service

# View logs
journalctl -u ledmatrix.service -f