From b445c272fbb08394530de6cd925f9da4c86d2486 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Wed, 24 Jun 2026 02:48:40 -0700 Subject: [PATCH] add boot-time synth-diagnostic.service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - synth-diagnostic.service: runs test-unit.py before pipeline services - Type=oneshot, After=prometheus-exporter, Before=pipeline services - Pipeline services: After=synth-diagnostic - deploy: restart prometheus-exporter → start synth-diagnostic → restart pipeline - install.sh: includes synth-diagnostic in SERVICES array --- install.sh | 2 +- justfile | 4 +++- scripts/run-tests.sh | 19 +++++++++++++++++++ system/led-matrix-viz.service | 2 +- system/midi-bridge.service | 2 +- system/pd-synth-onboard.service | 2 +- system/prometheus-exporter.service | 2 +- system/synth-diagnostic.service | 19 +++++++++++++++++++ 8 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 scripts/run-tests.sh create mode 100644 system/synth-diagnostic.service diff --git a/install.sh b/install.sh index 680c0df..6f889eb 100755 --- a/install.sh +++ b/install.sh @@ -3,7 +3,7 @@ set -euo pipefail REPO="/home/arduino/uno-q-audio-synth" -SERVICES=(midi-bridge pd-synth-onboard led-matrix-viz prometheus-exporter) +SERVICES=(synth-diagnostic midi-bridge pd-synth-onboard led-matrix-viz prometheus-exporter) for svc in "${SERVICES[@]}"; do sudo cp "$REPO/system/$svc.service" /etc/systemd/system/ diff --git a/justfile b/justfile index 63afd22..e74d350 100644 --- a/justfile +++ b/justfile @@ -104,7 +104,9 @@ deploy: cd {{REPO_DIR}} && git pull && \ chmod +x scripts/*.py scripts/*.sh 2>/dev/null; \ echo '{{BOARD_PASS}}' | sudo -S systemctl daemon-reload && \ - echo '{{BOARD_PASS}}' | sudo -S systemctl restart midi-bridge pd-synth-onboard led-matrix-viz prometheus-exporter && \ + echo '{{BOARD_PASS}}' | sudo -S systemctl restart prometheus-exporter && \ + echo '{{BOARD_PASS}}' | sudo -S systemctl start synth-diagnostic && \ + echo '{{BOARD_PASS}}' | sudo -S systemctl restart midi-bridge pd-synth-onboard led-matrix-viz && \ echo '[OK] Deployed + restarted'" # Start synth (onboard audio) diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh new file mode 100644 index 0000000..6b5bed0 --- /dev/null +++ b/scripts/run-tests.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# run-tests.sh — wrapper for test-unit.py with exit code mapping +set -euo pipefail + +BOARD="${BOARD_HOST:-192.168.9.167}" +cd /home/arduino/uno-q-audio-synth + +echo "[diag] Running synth pipeline diagnostics against $BOARD..." + +python3 scripts/test-unit.py "$BOARD" +exit_code=$? + +if [ $exit_code -eq 0 ]; then + echo "[diag] All tests PASSED — pipeline healthy" +else + echo "[diag] Tests FAILED (exit $exit_code) — check dashboard for details" +fi + +exit $exit_code \ No newline at end of file diff --git a/system/led-matrix-viz.service b/system/led-matrix-viz.service index 3e50767..23e6499 100644 --- a/system/led-matrix-viz.service +++ b/system/led-matrix-viz.service @@ -1,6 +1,6 @@ [Unit] Description=LED Matrix MIDI Visualization -After=arduino-router.service +After=arduino-router.service synth-diagnostic.service [Service] User=arduino diff --git a/system/midi-bridge.service b/system/midi-bridge.service index 7a68d5d..eedc3f6 100644 --- a/system/midi-bridge.service +++ b/system/midi-bridge.service @@ -1,6 +1,6 @@ [Unit] Description=MIDI rawmidi → Pd UDP bridge (auto-detects gadget/host) -After=multi-user.target +After=multi-user.target synth-diagnostic.service [Service] Type=simple diff --git a/system/pd-synth-onboard.service b/system/pd-synth-onboard.service index 65916da..1a12cb5 100644 --- a/system/pd-synth-onboard.service +++ b/system/pd-synth-onboard.service @@ -1,6 +1,6 @@ [Unit] Description=Pure Data Synth (Onboard PMIC Audio) -After=multi-user.target +After=multi-user.target synth-diagnostic.service Wants=midi-bridge.service [Service] diff --git a/system/prometheus-exporter.service b/system/prometheus-exporter.service index 53d6daf..30558fe 100644 --- a/system/prometheus-exporter.service +++ b/system/prometheus-exporter.service @@ -1,6 +1,6 @@ [Unit] Description=Prometheus metrics exporter for synth pipeline -After=multi-user.target +After=multi-user.target synth-diagnostic.service [Service] Type=simple diff --git a/system/synth-diagnostic.service b/system/synth-diagnostic.service new file mode 100644 index 0000000..bbccf1a --- /dev/null +++ b/system/synth-diagnostic.service @@ -0,0 +1,19 @@ +[Unit] +Description=Synth pipeline diagnostic — runs unit tests at boot +DefaultDependencies=no +After=multi-user.target prometheus-exporter.service +Before=midi-bridge.service pd-synth-onboard.service led-matrix-viz.service + +[Service] +Type=oneshot +ExecStart=/home/arduino/uno-q-audio-synth/scripts/run-tests.sh +StandardOutput=journal +StandardError=journal +RemainAfterExit=yes + +# Don't let failures cascade — critical for headless boot +# On failure: services won't start, board stays SSH-accessible +FailureAction=none + +[Install] +WantedBy=multi-user.target \ No newline at end of file