![]() |
Test whether Moode startup has completed from systemd service file - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7) +--- Thread: Test whether Moode startup has completed from systemd service file (/showthread.php?tid=5556) Pages:
1
2
|
Test whether Moode startup has completed from systemd service file - adrii - 05-03-2023 Hi The mpd_oled package for Moode installs a systemd service that should start mpd_oled after the Moode startup has completed. This is done with the following (example) service file Code: [Unit] and the helper script mpd_oled_launch_test: Code: #!/bin/bash With Moode 8.3.2, when mpd_oled is installed the Moode startup never completes, and wrkready is never set to 1, and mpd_oled_launch_test never makes it past the check for this. Eventually the mpd_oled service times out and wrkready is still set to 0. moodeutil -l says Code: pi@moode832:~ $ moodeutl -l Maybe this relates to the following recent Moode commit https://github.com/moode-player/moode/commit/495541ec31506bc47323da129757f4a9119e7efc Is there a way to work around this? How I can test the Moode startup has completed from a systemd service file? Adrian. RE: Test whether Moode startup has completed from systemd service file - Tim Curtis - 05-03-2023 It looks like a race condition issue given the error below which indicates worker.php has exited after testing for Linux startup complete for 3 minutes. Code: 20230503 121133 worker: ERROR: Linux startup failed to complete after waiting 180 seconds The command being used is: Code: systemctl is-system-running It returns "running" if all systemd units started successfully or "degraded" if one or more units fails to start. It can also return other values but Worker tests for only "running" and "degraded" and considers these values to mean that Linux startup has completed and Worker can proceed with moOde startup which eventually ends with the 'wrkready' param being set to '1'. So basically worker is in the 3 minute is-system-running loop waiting for all systemd units to complete with success or fail while mpd_oled systemd unit is in the launch test loop waiting for wrkready = 1. This means the mpd_oled systemd unit will not complete and still be in that loop after 3 minutes. At that time worker exits and 'wrkready' param is still '0'. Maybe running the launch test script from mpd_oled itself might work because this would allow the systemd unit to complete??? RE: Test whether Moode startup has completed from systemd service file - adrii - 05-03-2023 Hi Tim I might be able to have the mpd_oled service run the launch check as the ExecStart program, and start mpd_oled in this script after it waits for Moode to start. If this works out, then configuring the service this way should also work on other Player OSs. Adrian. RE: Test whether Moode startup has completed from systemd service file - adrii - 05-03-2023 Hi Tim This is essentially working. mpd_oled starts correctly at boot, the service can be started and stopped. The only issue is that stopping the service now leaves some pixels lit on the OLED, so it appears that when the service stops a script that runs mpd_oled it is not the same as when the service directly stops the mpd_oled process. I can probably fix this with an ExecStop in the service file to stop the mpd_oled process with an appropriate signal. Adrian. RE: Test whether Moode startup has completed from systemd service file - Tim Curtis - 05-03-2023 Sounds like it should work :-) I have a question about the until loops. Won't the condition part always return true? until ps -C worker.php > /dev/null; do I usually use something like pgrep -c worker.php != 0 RE: Test whether Moode startup has completed from systemd service file - adrii - 05-04-2023 Hi Tim When worker.php is not running the ps -C exit status is 1, which is not a success, and the until loop does not break out. When worker.php is running the ps -C exit status is 0, which is a success, and the until loop breaks out. E.g. see https://stackoverflow.com/a/21982743 Adrian. RE: Test whether Moode startup has completed from systemd service file - Tim Curtis - 05-04-2023 Ah yes the shell status $? Nvm RE: Test whether Moode startup has completed from systemd service file - fdealexa - 05-04-2023 Hi everyone, Could it be possible to test the state of mpd? I tried mpc play and mpc stop immediately: there is probably a better and more elegant way to test this. Sorry for butting in and best regards, Francesco RE: Test whether Moode startup has completed from systemd service file - bitlab - 05-04-2023 From script you can test the status if mpd is running as following Code: mpc Exit status is 0 when running. Alternative you can use the exit status of `systemctl status mpd`. You can also monitor the status of mpd by code. See for example my python script mpd2cdspvolume. RE: Test whether Moode startup has completed from systemd service file - adrii - 05-04-2023 Hi Francesco On Volumio and RuneAudio the mpd_oled service waits for mpd to be running before starting mpd_oled. On Moode there is a flag to say that the system startup has completed, and it should help avoid issues to wait for it to be set before running mpd_oled. Adrian. |