getStation(); $backend = $request->getStationBackend(); $frontend = $request->getStationFrontend(); return $response->withJson( new Entity\Api\StationServiceStatus( $backend->isRunning($station), $frontend->isRunning($station), $station->getHasStarted(), $station->getNeedsRestart() ) ); } public function restartAction(ServerRequest $request, Response $response): ResponseInterface { $station = $request->getStation(); $this->configuration->writeConfiguration($station, true); return $response->withJson(new Entity\Api\Status(true, __('Station restarted.'))); } public function frontendAction( ServerRequest $request, Response $response, $do = 'restart' ): ResponseInterface { $station = $request->getStation(); $frontend = $request->getStationFrontend(); switch ($do) { case 'stop': $frontend->stop($station); return $response->withJson(new Entity\Api\Status(true, __('Service stopped.'))); case 'start': $frontend->start($station); return $response->withJson(new Entity\Api\Status(true, __('Service started.'))); case 'reload': $frontend->write($station); $frontend->reload($station); return $response->withJson(new Entity\Api\Status(true, __('Service reloaded.'))); case 'restart': default: try { $frontend->stop($station); } catch (NotRunningException) { } $frontend->write($station); $frontend->start($station); return $response->withJson(new Entity\Api\Status(true, __('Service restarted.'))); } } public function backendAction( ServerRequest $request, Response $response, AutoDJ $autodj, $do = 'restart' ): ResponseInterface { $station = $request->getStation(); $backend = $request->getStationBackend(); switch ($do) { case 'skip': if ($backend instanceof Liquidsoap) { $backend->skip($station); } return $response->withJson(new Entity\Api\Status(true, __('Song skipped.'))); case 'disconnect': if ($backend instanceof Liquidsoap) { $backend->disconnectStreamer($station); } return $response->withJson(new Entity\Api\Status(true, __('Streamer disconnected.'))); case 'stop': $backend->stop($station); return $response->withJson(new Entity\Api\Status(true, __('Service stopped.'))); case 'start': $backend->start($station); return $response->withJson(new Entity\Api\Status(true, __('Service started.'))); case 'reload': $backend->write($station); $backend->reload($station); return $response->withJson(new Entity\Api\Status(true, __('Service reloaded.'))); case 'restart': default: try { $backend->stop($station); } catch (NotRunningException) { } $backend->write($station); $backend->start($station); return $response->withJson(new Entity\Api\Status(true, __('Service restarted.'))); } } }