Compare commits
2 Commits
f47d1a245f
...
feat/monit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2289156f57 | ||
|
|
f42b5a9cf5 |
@@ -116,13 +116,14 @@ task('webpack_encore:build', function () {
|
|||||||
sh -c '$installCmd'");
|
sh -c '$installCmd'");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Restart Docker containers (entrypoint gère migrations + cache:warmup automatiquement)
|
// Restart Docker containers (entrypoint gère les migrations automatiquement)
|
||||||
// Le cache est regénéré par l'entrypoint AVANT que FrankenPHP ne démarre,
|
// Le cache:clear est fait APRÈS le restart : Docker résout le bind mount au démarrage
|
||||||
// ce qui évite la race condition entre FrankenPHP et un docker exec concurrent.
|
// du container, pas dynamiquement. Avant restart, docker exec voit encore l'ancienne release.
|
||||||
desc('Restart Docker containers');
|
desc('Restart Docker containers');
|
||||||
task('docker:restart', function () {
|
task('docker:restart', function () {
|
||||||
run('docker restart mangarr-worker-commands mangarr-worker-events mangarr-worker-scheduler');
|
run('docker restart mangarr-worker-commands mangarr-worker-events mangarr-worker-scheduler');
|
||||||
run('docker restart mangarr');
|
run('docker restart mangarr');
|
||||||
|
run('docker exec mangarr php bin/console cache:clear --env=prod');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Pas de PHP sur l'hôte : désactiver les tâches Symfony qui en ont besoin
|
// Pas de PHP sur l'hôte : désactiver les tâches Symfony qui en ont besoin
|
||||||
|
|||||||
@@ -53,12 +53,11 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Vider le cache prod stale et le regénérer AVANT le démarrage de FrankenPHP.
|
# Vider le cache prod stale avant le démarrage des workers FrankenPHP.
|
||||||
# Sans ça, FrankenPHP et le deploy script compilent le container DI en parallèle
|
# Sans ça, les workers chargent l'ancien cache du volume Docker et crashent
|
||||||
# → fichiers partiellement écrits → crash au démarrage des workers.
|
# en boucle si les classes du cache ne correspondent plus à la version déployée.
|
||||||
if [ "$APP_ENV" = "prod" ]; then
|
if [ "$APP_ENV" = "prod" ]; then
|
||||||
rm -rf var/cache/prod
|
rm -rf var/cache/prod
|
||||||
php bin/console cache:warmup --env=prod
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var
|
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var
|
||||||
|
|||||||
36
src/Command/RunMonitoringCommand.php
Normal file
36
src/Command/RunMonitoringCommand.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use App\Domain\Manga\Application\Command\CheckMonitoredMangas;
|
||||||
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Messenger\MessageBusInterface;
|
||||||
|
|
||||||
|
#[AsCommand(
|
||||||
|
name: 'app:monitoring:run',
|
||||||
|
description: 'Déclenche immédiatement la vérification des mangas monitorés (sans attendre le scheduler)',
|
||||||
|
)]
|
||||||
|
class RunMonitoringCommand extends Command
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly MessageBusInterface $commandBus,
|
||||||
|
) {
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$output->writeln('Déclenchement du monitoring des mangas...');
|
||||||
|
|
||||||
|
$this->commandBus->dispatch(new CheckMonitoredMangas());
|
||||||
|
|
||||||
|
$output->writeln('<info>Vérification lancée. Les nouveaux chapitres détectés seront scrappés via le worker commands.</info>');
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Manga\Infrastructure\CommandHandler;
|
||||||
|
|
||||||
|
use App\Domain\Manga\Application\Command\CheckMonitoredMangas;
|
||||||
|
use App\Domain\Manga\Application\CommandHandler\CheckMonitoredMangasHandler;
|
||||||
|
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
||||||
|
|
||||||
|
#[AsMessageHandler]
|
||||||
|
readonly class SymfonyCheckMonitoredMangasHandler
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private CheckMonitoredMangasHandler $handler,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __invoke(CheckMonitoredMangas $command): void
|
||||||
|
{
|
||||||
|
$this->handler->handle($command);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user