Abstract URIs to stations/web containers.
This commit is contained in:
parent
02d070b6dd
commit
2bdc2616ad
|
@ -479,10 +479,16 @@ return [
|
|||
),
|
||||
|
||||
// Supervisor manager
|
||||
Supervisor\Supervisor::class => static function (Environment $settings, Psr\Log\LoggerInterface $logger) {
|
||||
/** @noinspection HttpUrlsUsage */
|
||||
Supervisor\Supervisor::class => static function (
|
||||
Environment $environment,
|
||||
Psr\Log\LoggerInterface $logger
|
||||
) {
|
||||
$uri = $environment->getUriToStations()
|
||||
->withPort(9001)
|
||||
->withPath('/RPC2');
|
||||
|
||||
$client = new fXmlRpc\Client(
|
||||
'http://' . ($settings->isDocker() ? 'stations' : '127.0.0.1') . ':9001/RPC2',
|
||||
(string)$uri,
|
||||
new fXmlRpc\Transport\PsrTransport(
|
||||
new Http\Factory\Guzzle\RequestFactory,
|
||||
new GuzzleHttp\Client
|
||||
|
|
|
@ -8,6 +8,8 @@ use App\Enums\ApplicationEnvironment;
|
|||
use App\Enums\ReleaseChannel;
|
||||
use App\Radio\Configuration;
|
||||
use App\Traits\AvailableStaticallyTrait;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
|
||||
class Environment
|
||||
|
@ -206,6 +208,24 @@ class Environment
|
|||
return ($compareVersion >= $version);
|
||||
}
|
||||
|
||||
public function getUriToWeb(): UriInterface
|
||||
{
|
||||
if ($this->isDocker()) {
|
||||
return $this->isDockerRevisionAtLeast(5)
|
||||
? new Uri('http://web')
|
||||
: new Uri('http://nginx');
|
||||
}
|
||||
|
||||
return new Uri('http://127.0.0.1');
|
||||
}
|
||||
|
||||
public function getUriToStations(): UriInterface
|
||||
{
|
||||
return $this->isDocker()
|
||||
? new Uri('http://stations')
|
||||
: new Uri('http://127.0.0.1');
|
||||
}
|
||||
|
||||
public function getLang(): ?string
|
||||
{
|
||||
return $this->data[self::LANG];
|
||||
|
|
|
@ -195,9 +195,12 @@ class Liquidsoap extends AbstractBackend
|
|||
*/
|
||||
public function command(Entity\Station $station, string $command_str): array
|
||||
{
|
||||
$hostname = ($this->environment->isDocker() ? 'stations' : 'localhost');
|
||||
$uri = $this->environment->getUriToStations()
|
||||
->withScheme('tcp')
|
||||
->withPort($this->getTelnetPort($station));
|
||||
|
||||
$fp = stream_socket_client(
|
||||
'tcp://' . $hostname . ':' . $this->getTelnetPort($station),
|
||||
(string)$uri,
|
||||
$errno,
|
||||
$errstr,
|
||||
20
|
||||
|
|
|
@ -129,14 +129,10 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
$stationTz = self::cleanUpString($station->getTimezone());
|
||||
$stationApiAuth = self::cleanUpString($station->getAdapterApiKey());
|
||||
|
||||
if ($this->environment->isDocker()) {
|
||||
$apiServiceUrl = ($this->environment->isDockerRevisionAtLeast(5))
|
||||
? 'web'
|
||||
: 'nginx';
|
||||
} else {
|
||||
$apiServiceUrl = 'localhost';
|
||||
}
|
||||
$stationApiUrl = self::cleanUpString('http://' . $apiServiceUrl . '/api/internal/' . $station->getId());
|
||||
$stationApiUrl = self::cleanUpString(
|
||||
(string)$this->environment->getUriToWeb()
|
||||
->withPath('/api/internal/' . $station->getId())
|
||||
);
|
||||
|
||||
$event->appendBlock(
|
||||
<<<EOF
|
||||
|
|
|
@ -54,8 +54,8 @@ class Icecast extends AbstractFrontend
|
|||
$feConfig = $station->getFrontendConfig();
|
||||
$radioPort = $feConfig->getPort();
|
||||
|
||||
/** @noinspection HttpUrlsUsage */
|
||||
$baseUrl = 'http://' . ($this->environment->isDocker() ? 'stations' : 'localhost') . ':' . $radioPort;
|
||||
$baseUrl = $this->environment->getUriToStations()
|
||||
->withPort($radioPort);
|
||||
|
||||
$npAdapter = $this->adapterFactory->getIcecastAdapter($baseUrl);
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ class SHOUTcast extends AbstractFrontend
|
|||
$feConfig = $station->getFrontendConfig();
|
||||
$radioPort = $feConfig->getPort();
|
||||
|
||||
/** @noinspection HttpUrlsUsage */
|
||||
$baseUrl = 'http://' . ($this->environment->isDocker() ? 'stations' : 'localhost') . ':' . $radioPort;
|
||||
$baseUrl = $this->environment->getUriToStations()
|
||||
->withPort($radioPort);
|
||||
|
||||
$npAdapter = $this->adapterFactory->getShoutcast2Adapter($baseUrl);
|
||||
$npAdapter->setAdminPassword($feConfig->getAdminPassword());
|
||||
|
|
Loading…
Reference in New Issue