05-03-2023, 10:35 AM
(05-03-2023, 09:44 AM)adrii Wrote: Hi Francesco
I am able to reproduce the issue. For some reason Moode does not set the wrkready parameter to 1 (which indicates that Moode startup has completed) and so mpd_oled never starts. I wonder if there is some kind of deadlock, where Moode is now waiting for the mpd_oled service to start before signalling that the Moode startup is complete? I'll try to track down the source of the issue.
Adrian.
I just did a quick test and the 'wrlready' param is definitely set to 1 at the end of worker.php startup. You can verify this by running the command below.
Code:
moodeutl -q "select value from cfg_system where param='wrkready'"
The beginning of the startup sequence in worker.php has been changed though to wait for Linux startup to complete first before continuing with moOde startup. This "wait" is done to allow the the Pi Imager /boot/firstrun.sh script to complete and create any WiFi credentials entered by user. These are subsequently imported by worker.php at a later point in moOde startup.
Maybe this introduces a race condition issue for the code in mpd_oled startup that waits for 'wrkready' = 1 condition.
The "wait for Linux" code is at the top of worker.php.
Code:
.
.
pcntl_signal(SIGHUP, SIG_IGN);
workerLog('worker: Successfully daemonized');
// Check for login user ID
if (empty(getUserID())) {
$logMsg = 'worker: ERROR: Login User ID does not exist, unable to continue';
workerLog($logMsg);
exit($logMsg . "\n");
}
// Check for Linux startup complete
workerLog('worker: Waiting for Linux startup...');
$maxLoops = 30;
$sleepTime = 6;
$linuxStartupComplete = false;
for ($i = 0; $i < $maxLoops; $i++) {
$result = sysCmd('systemctl is-system-running');
if ($result[0] == 'running' || $result[0] == 'degraded') {
$linuxStartupComplete = true;
break;
} else {
debugLog('worker: Wait ' . ($i + 1) . ' for Linux startup');
sleep($sleepTime);
}
}
if ($linuxStartupComplete === true) {
workerLog('worker: Linux startup complete');
} else {
$logMsg = 'worker: ERROR: Linux startup failed to complete after waiting ' . ($maxLoops * $sleepTime) . ' seconds';
workerLog($logMsg);
exit($logMsg . "\n");
}
.
.
.