From 9d3c7500ee39e1e4c757176b5a41ce918072e093 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 29 Sep 2026 11:00:01 +0800 Subject: fix(service): correct systemd module entrypoint [Problem] - The installed user service fails before recording starts. [Root Cause] - The unit invokes the package without its CLI module and places StartLimit directives in [Service]. [Solution] - Invoke mic_clipper.cli and move StartLimit directives to [Unit]. - Cover both rendered-unit requirements with the service test. [Impact] - The service template and its regression test are updated. --- src/mic_clipper/service.py | 6 +++--- tests/test_service.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mic_clipper/service.py b/src/mic_clipper/service.py index ecf5673..2b10710 100644 --- a/src/mic_clipper/service.py +++ b/src/mic_clipper/service.py @@ -17,18 +17,18 @@ def render_unit(python: Path, project_root: Path) -> str: Description=Offline voice-activated microphone clip recorder Wants=pipewire.service wireplumber.service pipewire-pulse.service After=pipewire.service wireplumber.service pipewire-pulse.service +StartLimitIntervalSec=300 +StartLimitBurst=10 [Service] Type=simple WorkingDirectory={project_root} Environment=PYTHONPATH={project_root / 'src'} -ExecStart={python} -m mic_clipper run +ExecStart={python} -m mic_clipper.cli run Restart=on-failure RestartSec=5s RestartSteps=5 RestartMaxDelaySec=60s -StartLimitIntervalSec=300 -StartLimitBurst=10 NoNewPrivileges=yes PrivateTmp=yes UMask=0077 diff --git a/tests/test_service.py b/tests/test_service.py index 2bda2ab..5aacbcc 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -3,13 +3,15 @@ from pathlib import Path from mic_clipper.service import install, render_unit, uninstall -def test_rendered_service_waits_for_audio_services_and_restarts_only_on_failure(): +def test_rendered_service_uses_cli_entrypoint_and_places_start_limits_in_unit(): unit = render_unit(Path("/runtime/python"), Path("/project")) assert "After=pipewire.service wireplumber.service pipewire-pulse.service" in unit + assert "StartLimitIntervalSec=300" in unit.split("[Service]", maxsplit=1)[0] + assert "StartLimitBurst=10" in unit.split("[Service]", maxsplit=1)[0] assert "Restart=on-failure" in unit assert "RestartMaxDelaySec=60s" in unit - assert "ExecStart=/runtime/python -m mic_clipper run" in unit + assert "ExecStart=/runtime/python -m mic_clipper.cli run" in unit assert "UMask=0077" in unit -- cgit v1.2.3