1 Commits

Author SHA1 Message Date
ext.jeremy.guillot@maxicoffee.domains
f47d1a245f fix(deploy): corriger la race condition sur le cache prod au déploiement
L'entrypoint faisait rm -rf var/cache/prod puis lançait FrankenPHP.
FrankenPHP compilait partiellement le container DI pendant que le script
Deployer lançait aussi cache:clear → fichiers manquants → crash.

- entrypoint.sh : ajouter cache:warmup après rm -rf, avant exec FrankenPHP
  (l'entrypoint est séquentiel, FrankenPHP ne démarre qu'une fois le cache prêt)
- deploy.php : supprimer le docker exec cache:clear devenu inutile et dangereux
2026-03-27 14:28:30 +01:00
4 changed files with 7 additions and 64 deletions

View File

@@ -116,14 +116,13 @@ task('webpack_encore:build', function () {
sh -c '$installCmd'");
});
// Restart Docker containers (entrypoint gère les migrations automatiquement)
// Le cache:clear est fait APRÈS le restart : Docker résout le bind mount au démarrage
// du container, pas dynamiquement. Avant restart, docker exec voit encore l'ancienne release.
// Restart Docker containers (entrypoint gère migrations + cache:warmup automatiquement)
// Le cache est regénéré par l'entrypoint AVANT que FrankenPHP ne démarre,
// ce qui évite la race condition entre FrankenPHP et un docker exec concurrent.
desc('Restart Docker containers');
task('docker:restart', function () {
run('docker restart mangarr-worker-commands mangarr-worker-events mangarr-worker-scheduler');
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

View File

@@ -53,11 +53,12 @@ if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
fi
fi
# Vider le cache prod stale avant le démarrage des workers FrankenPHP.
# Sans ça, les workers chargent l'ancien cache du volume Docker et crashent
# en boucle si les classes du cache ne correspondent plus à la version déployée.
# Vider le cache prod stale et le regénérer AVANT le démarrage de FrankenPHP.
# Sans ça, FrankenPHP et le deploy script compilent le container DI en parallèle
# → fichiers partiellement écrits → crash au démarrage des workers.
if [ "$APP_ENV" = "prod" ]; then
rm -rf var/cache/prod
php bin/console cache:warmup --env=prod
fi
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var

View File

@@ -1,36 +0,0 @@
<?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;
}
}

View File

@@ -1,21 +0,0 @@
<?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);
}
}