Avoid initial "Station Offline" state after a restart.

This commit is contained in:
Buster Neece 2023-01-31 13:39:01 -06:00
parent 9de8803beb
commit 18b1e88577
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
2 changed files with 12 additions and 14 deletions

View File

@ -29,6 +29,7 @@ final class FeedbackCommand extends AbstractCommand
// Process extra metadata sent by Liquidsoap (if it exists).
try {
$historyRow = $this->getSongHistory($station, $payload);
$this->em->persist($historyRow);
$this->historyRepo->changeCurrentSong($station, $historyRow);
@ -99,10 +100,7 @@ final class FeedbackCommand extends AbstractCommand
$this->queueRepo->trackPlayed($station, $sq);
$sh = Entity\SongHistory::fromQueue($sq);
$this->em->persist($sh);
return $sh;
return Entity\SongHistory::fromQueue($sq);
}
$history = new Entity\SongHistory($station, $media);

View File

@ -209,6 +209,8 @@ final class Configuration
$frontend?->write($station);
$backend?->write($station);
$this->markAsStarted($station);
// Reload Supervisord and process groups
if ($reloadSupervisor) {
$affected_groups = $this->reloadSupervisor();
@ -227,8 +229,6 @@ final class Configuration
}
}
}
$this->markAsStarted($station);
}
private function getSupervisorConfigFile(Station $station): string
@ -241,22 +241,24 @@ final class Configuration
Station $station,
bool $reloadSupervisor = true
): void {
$supervisorConfigFile = $this->getSupervisorConfigFile($station);
@unlink($supervisorConfigFile);
if ($reloadSupervisor) {
$this->stopForStation($station);
}
$station->setHasStarted(false);
$station->setNeedsRestart(false);
$station->clearCache();
$this->em->persist($station);
$this->em->flush();
$supervisorConfigFile = $this->getSupervisorConfigFile($station);
@unlink($supervisorConfigFile);
if ($reloadSupervisor) {
$this->stopForStation($station);
}
}
private function stopForStation(Station $station): void
{
$this->markAsStarted($station);
$station_group = 'station_' . $station->getId();
$affected_groups = $this->reloadSupervisor();
@ -266,8 +268,6 @@ final class Configuration
} catch (SupervisorException) {
}
}
$this->markAsStarted($station);
}
private function markAsStarted(Station $station): void