Re-merge setup:initialize and regular setup.

This commit is contained in:
Buster Neece 2023-01-15 16:30:22 -06:00
parent 963e803924
commit 3d386e529e
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
4 changed files with 50 additions and 85 deletions

View File

@ -22,7 +22,6 @@ return function (App\Event\BuildConsoleCommands $event) {
'azuracast:account:reset-password' => Command\Users\ResetPasswordCommand::class,
'azuracast:account:set-administrator' => Command\Users\SetAdministratorCommand::class,
'azuracast:cache:clear' => Command\ClearCacheCommand::class,
'azuracast:setup:initialize' => Command\InitializeCommand::class,
'azuracast:config:migrate' => Command\MigrateConfigCommand::class,
'azuracast:setup:migrate' => Command\MigrateDbCommand::class,
'azuracast:setup:fixtures' => Command\SetupFixturesCommand::class,

View File

@ -1,77 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Console\Command;
use App\Entity;
use App\Environment;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(
name: 'azuracast:setup:initialize',
description: 'Ensure key settings are initialized within AzuraCast.',
)]
final class InitializeCommand extends CommandAbstract
{
public function __construct(
private readonly Environment $environment,
private readonly Entity\Repository\StorageLocationRepository $storageLocationRepo
) {
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$io->title(__('Initialize AzuraCast'));
$io->writeln(__('Initializing essential settings...'));
$io->listing(
[
sprintf(
__('Environment: %s'),
$this->environment->getAppEnvironmentEnum()->getName()
),
sprintf(
__('Installation Method: %s'),
$this->environment->isDocker() ? 'Docker' : 'Ansible'
),
]
);
$io->newLine();
$io->section(__('Running Database Migrations'));
$this->runCommand(
$output,
'azuracast:setup:migrate'
);
$io->newLine();
$io->section(__('Generating Database Proxy Classes'));
$this->runCommand($output, 'orm:generate-proxies');
$io->newLine();
$io->section(__('Reload System Data'));
$this->runCommand($output, 'cache:clear');
// Ensure default storage locations exist.
$this->storageLocationRepo->createDefaultStorageLocations();
$io->newLine();
$io->success(
[
__('AzuraCast is now initialized.'),
]
);
return 0;
}
}

View File

@ -23,6 +23,7 @@ final class SetupCommand extends CommandAbstract
private readonly Environment $environment,
private readonly Entity\Repository\SettingsRepository $settingsRepo,
private readonly AzuraCastCentral $acCentral,
private readonly Entity\Repository\StorageLocationRepository $storageLocationRepo
) {
parent::__construct();
}
@ -31,7 +32,8 @@ final class SetupCommand extends CommandAbstract
{
$this->addOption('update', null, InputOption::VALUE_NONE)
->addOption('load-fixtures', null, InputOption::VALUE_NONE)
->addOption('release', null, InputOption::VALUE_NONE);
->addOption('release', null, InputOption::VALUE_NONE)
->addOption('init', null, InputOption::VALUE_NONE);
}
protected function execute(InputInterface $input, OutputInterface $output): int
@ -40,20 +42,57 @@ final class SetupCommand extends CommandAbstract
$update = (bool)$input->getOption('update');
$loadFixtures = (bool)$input->getOption('load-fixtures');
$isInit = (bool)$input->getOption('init');
$io->title(__('AzuraCast Setup'));
$io->writeln(__('Welcome to AzuraCast. Please wait while some key dependencies of AzuraCast are set up...'));
if ($isInit) {
$update = true;
$loadFixtures = false;
}
$this->runCommand($output, 'azuracast:setup:initialize');
if (!$update && !$this->environment->isProduction()) {
$loadFixtures = true;
}
if ($loadFixtures || (!$this->environment->isProduction() && !$update)) {
// Header display
if ($isInit) {
$io->title(__('AzuraCast Initializing...'));
} else {
$io->title(__('AzuraCast Setup'));
$io->writeln(
__('Welcome to AzuraCast. Please wait while some key dependencies of AzuraCast are set up...')
);
$io->newLine();
}
$io->section(__('Running Database Migrations'));
$this->runCommand(
$output,
'azuracast:setup:migrate'
);
$io->newLine();
$io->section(__('Generating Database Proxy Classes'));
$this->runCommand($output, 'orm:generate-proxies');
$io->newLine();
$io->section(__('Reload System Data'));
$this->runCommand($output, 'cache:clear');
// Ensure default storage locations exist.
$this->storageLocationRepo->createDefaultStorageLocations();
$io->newLine();
if ($loadFixtures) {
$io->section(__('Installing Data Fixtures'));
$this->runCommand($output, 'azuracast:setup:fixtures');
$io->newLine();
}
$io->newLine();
$io->section(__('Refreshing All Stations'));
$this->runCommand($output, 'azuracast:station-queues:clear');
@ -69,6 +108,10 @@ final class SetupCommand extends CommandAbstract
$restartArgs
);
if ($isInit) {
return 0;
}
// Update system setting logging when updates were last run.
$settings = $this->settingsRepo->readSettings();
$settings->updateUpdateLastRun();

View File

@ -11,7 +11,7 @@ dockerize -template "/etc/php/${PHP_VERSION}/fpm/05-azuracast.ini.tmpl:/etc/php/
gosu azuracast php /var/azuracast/www/bin/uptime_wait || exit 1
# Initialize before running FPM
gosu azuracast azuracast_cli azuracast:setup:initialize || exit 1
gosu azuracast azuracast_cli azuracast:setup --init || exit 1
# Run initial Acme check
gosu azuracast azuracast_cli azuracast:acme:get-certificate || true