BusDriver Posted June 7, 2020 Posted June 7, 2020 On my Orange Pi Zero I run Armbian Buster and the only software running is Shairport. Unfortunately I used to have a crackling noise every 20-40 secund which was solved after entering root@orangepizero:~# renice -n -19 -u shairport-sync 110 (user ID) old priority 0, new priority -19 So far so good - but after a reboot the prio is again 0. So I tried to use nice nice -19 shairport-sync but after a reboot the prio was again 0 How can I set the priority of all process run by the user (-u) “shairport-sync” to -19 when they start?
BusDriver Posted June 7, 2020 Author Posted June 7, 2020 Could I achieve this in /etc/security/limits.conf ? If yes, what would be a correct entry?
BusDriver Posted June 8, 2020 Author Posted June 8, 2020 In the meantime have tried many entries, nothing worked. Seems like limits.conf can only set the limit, not set the standard priority when a process starts
xwiggen Posted June 8, 2020 Posted June 8, 2020 modify /etc/init.d/shairport-sync, -19 will not be pretty overall. Try changing preemption model in kernel and settings for shairport-sync (latency) if any.
BusDriver Posted June 9, 2020 Author Posted June 9, 2020 Many thanks for pointing me to the init.d file. I did read the pages I could find on how to enter commands to it, I tried several ways but still the priority is low. What I tried: START_ARGS="--chuid ${USER}" "nice -n -19 shairport-sync" and START_ARGS="--chuid ${USER}" "renice -n -19 -u shairport-sync" But still the priority is 0 after reboot
Werner Posted June 9, 2020 Posted June 9, 2020 Doesn't Debian use systemd for their stuff? The init.d files might be there only for legacy reasons. You probably have to edit the corresponding systemd file. Check if you find it in /lib/systemd/system
BusDriver Posted June 9, 2020 Author Posted June 9, 2020 Thanks for pointing me here, this triggered some research- in /lib/systemd/system I do find the shairport-sync.service file. There I entered the ExecStartPost command [Unit] Description=Shairport Sync - AirPlay Audio Receiver After=sound.target Requires=avahi-daemon.service After=avahi-daemon.service Wants=network-online.target After=network.target network-online.target [Service] ExecStart=/usr/local/bin/shairport-sync User=shairport-sync Group=shairport-syncExecStartPost=renice -n -19 -u shairport-sync [Install] WantedBy=multi-user.target But the only effect this had was killing the service completely seems like my syntax is wrong. In https://www.freedesktop.org/software/systemd/man/systemd.exec.html# I found the info that I can use "Nice" - how nice! So the new config is [Unit] Description=Shairport Sync - AirPlay Audio Receiver After=sound.target Requires=avahi-daemon.service After=avahi-daemon.service Wants=network-online.target After=network.target network-online.target [Service] ExecStart=/usr/local/bin/shairport-sync User=shairport-sync Group=shairport-syncNice=-19 [Install] WantedBy=multi-user.target And yeah, this works! Many many thanks! So to wrap up the issue and the solution: Shairport-Service used to have cracks and noise which disappeared by entering renice -n -19 -u shairport-sync after start. However, after Reboot, this was lost. So the solution was to go to /lib/systemd/system , edit the existing shairport-sync.service file by adding Nice=-19 to the config. Check if this works by rebooting and doing "top".
Werner Posted June 9, 2020 Posted June 9, 2020 Try nice instead of renice. renice is used to adjust the nice-level of already existing processes. nice is used to give a newly created proces a specific priority.
BusDriver Posted June 9, 2020 Author Posted June 9, 2020 Correct, in the successful config I have used nice. The reason why I tried renice in the first try was, that I expected the service to be running already. It would have been more like a hack to "command-line" renice after start. setting it properly in the service config is the better way.
Recommended Posts