music-assistant: Tell players to restart on startup
I haven't fully determined why, but when the Music Assistant server restarts, it marks the _shairport-sync_ players as offline and will not allow playing to them. The only way I have found to work around this is to restart the players after the server restarts. As that's pretty cumbersome and annoying, I naturally want to automate it, so I've created this rudimentary synchronization technique using _ntfy_: each player listens for notifications on a specific topic, and upon receiving one, tells _shairport-sync_ to exit. With the `Restart=` property configured on the _shairport-sync.service_ unit, _systemd_ will restart the service, which causes Music Assistant to discover the player again.pull/78/head
parent
ae1d952297
commit
42a7964991
|
@ -16,6 +16,25 @@ resources:
|
|||
- music-assistant.yaml
|
||||
- ingress.yaml
|
||||
|
||||
patches:
|
||||
- patch: |
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: music-assistant
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: music-assistant
|
||||
lifecycle:
|
||||
postStart:
|
||||
exec:
|
||||
command:
|
||||
- wget
|
||||
- -qO-
|
||||
- http://ntfy.ntfy:2586/0e386416-ac43-488c-b709-efac8e2555a3/publish?message=restart
|
||||
|
||||
images:
|
||||
- name: ghcr.io/music-assistant/server
|
||||
newTag: 2.6.0b18
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# vim: set ft=systemd :
|
||||
|
||||
# In order for this to be effective, `shairport-sync.service` needs a
|
||||
# configuration override to enable auto-restart, e.g.:
|
||||
#
|
||||
# [Service]
|
||||
# Restart=always
|
||||
# RestartSec=1
|
||||
|
||||
[Unit]
|
||||
Description=Restart shairport-sync when music-assistant restarts
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/libexec/restart-sync.sh
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
|
||||
[Install]
|
||||
WantedBy=shairport-sync.service
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
TOPIC=0e386416-ac43-488c-b709-efac8e2555a3
|
||||
NTFY=https://ntfy.pyrocufflink.net
|
||||
DELAY=10
|
||||
|
||||
url=$(printf '%s/%s/raw' "${NTFY}" "${TOPIC}")
|
||||
|
||||
curl -sN "${url}" \
|
||||
| stdbuf -o0 grep restart \
|
||||
| while read l; do
|
||||
printf 'Restarting shairport-sync in %d seconds\n' "$DELAY" >&2
|
||||
sleep $DELAY
|
||||
busctl call org.gnome.ShairportSync /org/gnome/ShairportSync org.gnome.ShairportSync Quit
|
||||
done
|
Loading…
Reference in New Issue