Move nginx 9010 port to 6010; use sockets for MariaDB.
This commit is contained in:
parent
5fbb500c6a
commit
5dc6bf8742
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Command\Backup;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Console\Command\Traits\PassThruProcess;
|
||||
use App\Environment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
abstract class AbstractBackupCommand extends CommandAbstract
|
||||
{
|
||||
use PassThruProcess;
|
||||
|
||||
public function __construct(
|
||||
protected Environment $environment,
|
||||
protected EntityManagerInterface $em
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function getDatabaseSettingsAsCliFlags(): array
|
||||
{
|
||||
$connSettings = $this->environment->getDatabaseSettings();
|
||||
|
||||
$commandEnvVars = [
|
||||
'DB_DATABASE' => $connSettings['dbname'],
|
||||
'DB_USERNAME' => $connSettings['user'],
|
||||
'DB_PASSWORD' => $connSettings['password'],
|
||||
];
|
||||
|
||||
$commandFlags = [
|
||||
'--user=$DB_USERNAME',
|
||||
'--password=$DB_PASSWORD',
|
||||
];
|
||||
|
||||
if (isset($connSettings['unix_socket'])) {
|
||||
$commandFlags[] = '--socket=$DB_SOCKET';
|
||||
$commandEnvVars['DB_SOCKET'] = $connSettings['unix_socket'];
|
||||
} else {
|
||||
$commandFlags[] = '--host=$DB_HOST';
|
||||
$commandFlags[] = '--port=$DB_PORT';
|
||||
$commandEnvVars['DB_HOST'] = $connSettings['host'];
|
||||
$commandEnvVars['DB_PORT'] = $connSettings['port'];
|
||||
}
|
||||
|
||||
return [$commandFlags, $commandEnvVars];
|
||||
}
|
||||
}
|
|
@ -4,8 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Console\Command\Backup;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Console\Command\Traits;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -24,16 +22,14 @@ use const PATHINFO_EXTENSION;
|
|||
name: 'azuracast:backup',
|
||||
description: 'Back up the AzuraCast database and statistics (and optionally media).',
|
||||
)]
|
||||
class BackupCommand extends CommandAbstract
|
||||
class BackupCommand extends AbstractBackupCommand
|
||||
{
|
||||
use Traits\PassThruProcess;
|
||||
|
||||
public function __construct(
|
||||
protected Environment $environment,
|
||||
protected EntityManagerInterface $em,
|
||||
Environment $environment,
|
||||
EntityManagerInterface $em,
|
||||
protected Entity\Repository\StorageLocationRepository $storageLocationRepo,
|
||||
) {
|
||||
parent::__construct();
|
||||
parent::__construct($environment, $em);
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
|
@ -117,22 +113,19 @@ class BackupCommand extends CommandAbstract
|
|||
|
||||
$path_db_dump = $tmp_dir_mariadb . '/db.sql';
|
||||
|
||||
$connSettings = $this->environment->getDatabaseSettings();
|
||||
[$commandFlags, $commandEnvVars] = $this->getDatabaseSettingsAsCliFlags();
|
||||
|
||||
$commandFlags[] = '--add-drop-table';
|
||||
$commandFlags[] = '--default-character-set=UTF8MB4';
|
||||
|
||||
$commandEnvVars['DB_DEST'] = $path_db_dump;
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength
|
||||
$this->passThruProcess(
|
||||
$io,
|
||||
'mysqldump --host=$DB_HOST --user=$DB_USERNAME --password=$DB_PASSWORD --add-drop-table --default-character-set=UTF8MB4 $DB_DATABASE > $DB_DEST',
|
||||
'mysqldump ' . implode(' ', $commandFlags) . ' $DB_DATABASE > $DB_DEST',
|
||||
$tmp_dir_mariadb,
|
||||
[
|
||||
'DB_HOST' => $connSettings['host'],
|
||||
'DB_DATABASE' => $connSettings['dbname'],
|
||||
'DB_USERNAME' => $connSettings['user'],
|
||||
'DB_PASSWORD' => $connSettings['password'],
|
||||
'DB_DEST' => $path_db_dump,
|
||||
]
|
||||
$commandEnvVars
|
||||
);
|
||||
// phpcs:enable
|
||||
|
||||
$files_to_backup[] = $path_db_dump;
|
||||
$io->newLine();
|
||||
|
|
|
@ -4,10 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Console\Command\Backup;
|
||||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Console\Command\Traits;
|
||||
use App\Environment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
@ -22,17 +18,8 @@ use const PATHINFO_EXTENSION;
|
|||
name: 'azuracast:restore',
|
||||
description: 'Restore a backup previously generated by AzuraCast.',
|
||||
)]
|
||||
class RestoreCommand extends CommandAbstract
|
||||
class RestoreCommand extends AbstractBackupCommand
|
||||
{
|
||||
use Traits\PassThruProcess;
|
||||
|
||||
public function __construct(
|
||||
protected Environment $environment,
|
||||
protected EntityManagerInterface $em
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('path', InputArgument::REQUIRED)
|
||||
|
@ -120,7 +107,6 @@ class RestoreCommand extends CommandAbstract
|
|||
}
|
||||
|
||||
$conn = $this->em->getConnection();
|
||||
$connSettings = $this->environment->getDatabaseSettings();
|
||||
|
||||
// Drop all preloaded tables prior to running a DB dump backup.
|
||||
$conn->executeQuery('SET FOREIGN_KEY_CHECKS = 0');
|
||||
|
@ -129,18 +115,15 @@ class RestoreCommand extends CommandAbstract
|
|||
}
|
||||
$conn->executeQuery('SET FOREIGN_KEY_CHECKS = 1');
|
||||
|
||||
[$commandFlags, $commandEnvVars] = $this->getDatabaseSettingsAsCliFlags();
|
||||
|
||||
$commandEnvVars['DB_DUMP'] = $path_db_dump;
|
||||
|
||||
$this->passThruProcess(
|
||||
$io,
|
||||
'mysql --host=$DB_HOST --user=$DB_USERNAME --password=$DB_PASSWORD $DB_DATABASE < $DB_DUMP',
|
||||
'mysql ' . implode(' ', $commandFlags) . ' $DB_DATABASE < $DB_DUMP',
|
||||
$tmp_dir_mariadb,
|
||||
[
|
||||
'DB_HOST' => $connSettings['host'],
|
||||
'DB_DATABASE' => $connSettings['dbname'],
|
||||
'DB_USERNAME' => $connSettings['user'],
|
||||
'DB_PASSWORD' => $connSettings['password'],
|
||||
'DB_DUMP' => $path_db_dump,
|
||||
]
|
||||
$commandEnvVars
|
||||
);
|
||||
|
||||
(new Filesystem())->remove($tmp_dir_mariadb);
|
||||
|
|
|
@ -206,12 +206,12 @@ class Environment
|
|||
return $this->getParentDirectory() . '/stations';
|
||||
}
|
||||
|
||||
public function getUriToWeb(): UriInterface
|
||||
public function getInternalUri(): UriInterface
|
||||
{
|
||||
return new Uri('http://127.0.0.1:9010');
|
||||
return new Uri('http://127.0.0.1:6010');
|
||||
}
|
||||
|
||||
public function getUriToStations(): UriInterface
|
||||
public function getLocalUri(): UriInterface
|
||||
{
|
||||
return new Uri('http://127.0.0.1');
|
||||
}
|
||||
|
@ -286,13 +286,21 @@ class Environment
|
|||
*/
|
||||
public function getDatabaseSettings(): array
|
||||
{
|
||||
return [
|
||||
'host' => $this->data[self::DB_HOST] ?? 'localhost',
|
||||
'port' => (int)($this->data[self::DB_PORT] ?? 3306),
|
||||
$dbSettings = [
|
||||
'dbname' => $this->data[self::DB_NAME] ?? 'azuracast',
|
||||
'user' => $this->data[self::DB_USER] ?? 'azuracast',
|
||||
'password' => $this->data[self::DB_PASSWORD] ?? 'azur4c457',
|
||||
];
|
||||
|
||||
$host = $this->data[self::DB_HOST] ?? 'localhost';
|
||||
if ('localhost' === $host) {
|
||||
$dbSettings['unix_socket'] = '/run/mysqld/mysqld.sock';
|
||||
} else {
|
||||
$dbSettings['host'] = $host;
|
||||
$dbSettings['port'] = (int)($this->data[self::DB_PORT] ?? 3306);
|
||||
}
|
||||
|
||||
return $dbSettings;
|
||||
}
|
||||
|
||||
public function enableRedis(): bool
|
||||
|
|
|
@ -148,7 +148,7 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
|
||||
$stationApiAuth = self::cleanUpString($station->getAdapterApiKey());
|
||||
$stationApiUrl = self::cleanUpString(
|
||||
(string)$this->environment->getUriToWeb()
|
||||
(string)$this->environment->getInternalUri()
|
||||
->withPath('/api/internal/' . $station->getId() . '/liquidsoap')
|
||||
);
|
||||
|
||||
|
|
|
@ -22,10 +22,9 @@ class Configuration
|
|||
public const DEFAULT_PORT_MIN = 8000;
|
||||
public const DEFAULT_PORT_MAX = 8499;
|
||||
public const PROTECTED_PORTS = [
|
||||
9000, // PHP-FPM external
|
||||
9001, // Supervisord
|
||||
9005, // PHP-FPM internal
|
||||
9010, // Nginx internal
|
||||
3306, // MariaDB
|
||||
6010, // Nginx internal
|
||||
6379, // Redis
|
||||
8080, // Common debug port
|
||||
80, // HTTP
|
||||
443, // HTTPS
|
||||
|
|
|
@ -54,7 +54,7 @@ class Icecast extends AbstractFrontend
|
|||
$feConfig = $station->getFrontendConfig();
|
||||
$radioPort = $feConfig->getPort();
|
||||
|
||||
$baseUrl = $this->environment->getUriToStations()
|
||||
$baseUrl = $this->environment->getLocalUri()
|
||||
->withPort($radioPort);
|
||||
|
||||
$npAdapter = $this->adapterFactory->getIcecastAdapter($baseUrl);
|
||||
|
@ -241,7 +241,7 @@ class Icecast extends AbstractFrontend
|
|||
|
||||
$bannedCountries = $station->getFrontendConfig()->getBannedCountries() ?? [];
|
||||
if (!empty($bannedCountries)) {
|
||||
$mountAuthenticationUrl = $this->environment->getUriToWeb()
|
||||
$mountAuthenticationUrl = $this->environment->getInternalUri()
|
||||
->withPath('/api/internal/' . $station->getIdRequired() . '/listener-auth')
|
||||
->withQuery(
|
||||
http_build_query([
|
||||
|
|
|
@ -54,7 +54,7 @@ class Shoutcast extends AbstractFrontend
|
|||
$feConfig = $station->getFrontendConfig();
|
||||
$radioPort = $feConfig->getPort();
|
||||
|
||||
$baseUrl = $this->environment->getUriToStations()
|
||||
$baseUrl = $this->environment->getLocalUri()
|
||||
->withPort($radioPort);
|
||||
|
||||
$npAdapter = $this->adapterFactory->getShoutcast2Adapter($baseUrl);
|
||||
|
|
|
@ -34,7 +34,7 @@ else
|
|||
fi
|
||||
|
||||
APP_ENV="${APP_ENV:-production}"
|
||||
UPDATE_REVISION="${UPDATE_REVISION:-80}"
|
||||
UPDATE_REVISION="${UPDATE_REVISION:-81}"
|
||||
|
||||
echo "Updating AzuraCast (Environment: $APP_ENV, Update revision: $UPDATE_REVISION)"
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ upstream redis_server {
|
|||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:9010;
|
||||
listen 127.0.0.1:6010;
|
||||
|
||||
root {{ app_base }}/www/web;
|
||||
index index.php;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
when: update_revision|int < 63
|
||||
|
||||
- role: "nginx"
|
||||
when: update_revision|int < 80
|
||||
when: update_revision|int < 81
|
||||
|
||||
- role: "redis"
|
||||
when: update_revision|int < 57
|
||||
|
|
|
@ -14,7 +14,7 @@ upstream redis_server {
|
|||
|
||||
# Internal connection handler for PubSub and internal API calls
|
||||
server {
|
||||
listen 127.0.0.1:9010;
|
||||
listen 127.0.0.1:6010;
|
||||
|
||||
root /var/azuracast/www/web;
|
||||
index index.php;
|
||||
|
|
Loading…
Reference in New Issue