Avoid initial "Station Offline" state after a restart.
This commit is contained in:
parent
9de8803beb
commit
18b1e88577
|
@ -29,6 +29,7 @@ final class FeedbackCommand extends AbstractCommand
|
||||||
// Process extra metadata sent by Liquidsoap (if it exists).
|
// Process extra metadata sent by Liquidsoap (if it exists).
|
||||||
try {
|
try {
|
||||||
$historyRow = $this->getSongHistory($station, $payload);
|
$historyRow = $this->getSongHistory($station, $payload);
|
||||||
|
$this->em->persist($historyRow);
|
||||||
|
|
||||||
$this->historyRepo->changeCurrentSong($station, $historyRow);
|
$this->historyRepo->changeCurrentSong($station, $historyRow);
|
||||||
|
|
||||||
|
@ -99,10 +100,7 @@ final class FeedbackCommand extends AbstractCommand
|
||||||
|
|
||||||
$this->queueRepo->trackPlayed($station, $sq);
|
$this->queueRepo->trackPlayed($station, $sq);
|
||||||
|
|
||||||
$sh = Entity\SongHistory::fromQueue($sq);
|
return Entity\SongHistory::fromQueue($sq);
|
||||||
$this->em->persist($sh);
|
|
||||||
|
|
||||||
return $sh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$history = new Entity\SongHistory($station, $media);
|
$history = new Entity\SongHistory($station, $media);
|
||||||
|
|
|
@ -209,6 +209,8 @@ final class Configuration
|
||||||
$frontend?->write($station);
|
$frontend?->write($station);
|
||||||
$backend?->write($station);
|
$backend?->write($station);
|
||||||
|
|
||||||
|
$this->markAsStarted($station);
|
||||||
|
|
||||||
// Reload Supervisord and process groups
|
// Reload Supervisord and process groups
|
||||||
if ($reloadSupervisor) {
|
if ($reloadSupervisor) {
|
||||||
$affected_groups = $this->reloadSupervisor();
|
$affected_groups = $this->reloadSupervisor();
|
||||||
|
@ -227,8 +229,6 @@ final class Configuration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->markAsStarted($station);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getSupervisorConfigFile(Station $station): string
|
private function getSupervisorConfigFile(Station $station): string
|
||||||
|
@ -241,22 +241,24 @@ final class Configuration
|
||||||
Station $station,
|
Station $station,
|
||||||
bool $reloadSupervisor = true
|
bool $reloadSupervisor = true
|
||||||
): void {
|
): void {
|
||||||
$supervisorConfigFile = $this->getSupervisorConfigFile($station);
|
|
||||||
@unlink($supervisorConfigFile);
|
|
||||||
if ($reloadSupervisor) {
|
|
||||||
$this->stopForStation($station);
|
|
||||||
}
|
|
||||||
|
|
||||||
$station->setHasStarted(false);
|
$station->setHasStarted(false);
|
||||||
$station->setNeedsRestart(false);
|
$station->setNeedsRestart(false);
|
||||||
$station->clearCache();
|
$station->clearCache();
|
||||||
|
|
||||||
$this->em->persist($station);
|
$this->em->persist($station);
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
|
$supervisorConfigFile = $this->getSupervisorConfigFile($station);
|
||||||
|
@unlink($supervisorConfigFile);
|
||||||
|
if ($reloadSupervisor) {
|
||||||
|
$this->stopForStation($station);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function stopForStation(Station $station): void
|
private function stopForStation(Station $station): void
|
||||||
{
|
{
|
||||||
|
$this->markAsStarted($station);
|
||||||
|
|
||||||
$station_group = 'station_' . $station->getId();
|
$station_group = 'station_' . $station->getId();
|
||||||
$affected_groups = $this->reloadSupervisor();
|
$affected_groups = $this->reloadSupervisor();
|
||||||
|
|
||||||
|
@ -266,8 +268,6 @@ final class Configuration
|
||||||
} catch (SupervisorException) {
|
} catch (SupervisorException) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->markAsStarted($station);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function markAsStarted(Station $station): void
|
private function markAsStarted(Station $station): void
|
||||||
|
|
Loading…
Reference in New Issue