liquidsoap-daemon
liquidsoap-daemon copied to clipboard
Use template for systemd units?
Hi,
I was thinking about improving my monit based liq handling with your new approach here, and wondered if we could benefit from the unit templates for systemd to keep things a bit tidier: https://www.freedesktop.org/software/systemd/man/systemd.unit.html https://fedoramagazine.org/systemd-template-unit-files/
I'll try to make a PR, but it seems rather "not too hard" to evolve your script to use this, and might end up quite cleaner ;)
(Edited to escape asterisks so they show up and don't put in italics...)
I absolutely agree with this. Issue #1997 on the main liquidsoap project touches on this very subject, where neuss0r linked to someone's systemd unit template configuration for liquidsoap. I tried it out and have been running it for a few months now (although with only a single script). Rather than needing to run daemonize on each Liquidsoap script you have (if I understand the daemonize script correctly), a single unit configuration can handle them all with "liquidsoap@
systemctl start liquidsoap@aviaryradio (starts /etc/liquidsoap/aviaryradio.liq) systemctl start liquidsoap@technotronic (starts /etc/liquidsoap/technotronic.liq) (and so on and so forth)
Once you have several scripts running, you can send commands to all of them using "liquidsoap@*". So the post-rotate script for logrotate only needs a single line sending a signal to "liquidsoap@*" rather than identifying all necessary PIDs and looping through to send a signal to each one individually.
In short, I think this is a great avenue to explore and is ready to handle multiple scripts right out of the box. I'm just not quite certain how to explore it inside the existing framework of liquidsoap-daemon.
If anyone wants to try it out, this is what I've been using:
[Unit]
Description=Liquidsoap
Documentation=http://liquidsoap.fm man:liquidsoap(1)
Requires=sound.target
Wants=network-online.target
After=network-online.target sound.target
[Service]
PermissionsStartOnly=true
RuntimeDirectory=liquidsoap
ExecStartPre=-/bin/mkdir -p /var/log/liquidsoap
ExecStartPre=-/bin/chown liquidsoap /var/log/liquidsoap
ExecStart=/usr/bin/liquidsoap -v /etc/liquidsoap/%i.liq
User=liquidsoap
Group=liquidsoap
[Install]
WantedBy=multi-user.target