Skip to content

Commit

Permalink
fix: add services for playlist reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
spameier committed Nov 8, 2023
1 parent bf98b63 commit f674d20
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/systemd/klangbecken-reload-jingles.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Reload Jingles playlist after expire to workaround missing inotify support

[Service]
Type=simple
EnvironmentFile=/etc/klangbecken.conf
ExecStart=/bin/bash -c 'echo "jingles.reload" | nc -U ${KLANGBECKEN_PLAYER_SOCKET}'
User=liquidsoap
Group=liquidsoap

[Install]
WantedBy=multi-user.target
8 changes: 8 additions & 0 deletions doc/systemd/klangbecken-reload-jingles.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Run klangbecken-reload-jingles.service hourly at :30

[Timer]
OnCalendar=*-*-* *:05:30

[Install]
WantedBy=timers.target
21 changes: 21 additions & 0 deletions klangbecken/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,27 @@ def disable_expired_cmd(data_dir):
[MetadataChange("weight", 0)],
)

# currently liquidsoap does not notify when the playlist changes
# solving this the dirty way, because we hope that liquidsoap supports
# inotify properly in newer version than 1.3.7 which would make reloading
# the playlist obsolete.
from .player import LiquidsoapClient
from os import environ

if "KLANGBECKEN_PLAYER_SOCKET" in environ:
player_socket = environ["KLANGBECKEN_PLAYER_SOCKET"]
try:
with LiquidsoapClient(player_socket) as client:
client.command("jingles.reload")
except FileNotFoundError:
print(f"Could not communicate with Liquidsoap via socket {player_socket}")
exit(1)
else:
print(
"Liquidsoap player socket environment variable (KLANGBECKEN_PLAYER_SOCKET) is not defined."
)
exit(1)


def main():
"""Klangbecken audio playout system.
Expand Down

0 comments on commit f674d20

Please sign in to comment.