add new route for global reindex

This commit is contained in:
team 1
2026-02-17 16:00:59 +01:00
parent 0b96ce6188
commit 2c443c0f1e
4 changed files with 159 additions and 57 deletions

View File

@@ -11,6 +11,7 @@ use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(name: 'mto:agent:ingest:run')]
@@ -26,12 +27,14 @@ final class IngestRunJobCommand extends Command
protected function configure(): void
{
$this
->addArgument('jobId', InputArgument::REQUIRED, 'UUID of IngestJob');
->addArgument('jobId', InputArgument::REQUIRED, 'UUID of IngestJob')
->addOption('dry-run', null, InputOption::VALUE_NONE, 'Run without executing heavy operations');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$jobId = (string) $input->getArgument('jobId');
$dryRun = (bool) $input->getOption('dry-run');
/** @var IngestJob|null $job */
$job = $this->em->getRepository(IngestJob::class)->find($jobId);
@@ -41,19 +44,37 @@ final class IngestRunJobCommand extends Command
return Command::FAILURE;
}
// Idempotenz: wenn der Job bereits beendet ist, einfach ok zurück.
if (in_array($job->getStatus(), [IngestJob::STATUS_COMPLETED, IngestJob::STATUS_FAILED, IngestJob::STATUS_ABORTED], true)) {
// Idempotenz: Bereits abgeschlossene Jobs nicht erneut ausführen
if (in_array($job->getStatus(), [
IngestJob::STATUS_COMPLETED,
IngestJob::STATUS_FAILED,
IngestJob::STATUS_ABORTED,
], true)) {
$output->writeln('<info>Job already finished.</info>');
return Command::SUCCESS;
}
try {
$output->writeln(sprintf('<info>Running ingest job %s ...</info>', (string) $job->getId()));
$this->orchestrator->runExistingJob($job, false);
$output->writeln('<info>Job completed.</info>');
$output->writeln(sprintf(
'<info>Running ingest job %s (type: %s)...</info>',
(string) $job->getId(),
$job->getType()
));
$this->orchestrator->runExistingJob($job, $dryRun);
$output->writeln('<info>Job completed successfully.</info>');
return Command::SUCCESS;
} catch (\Throwable $e) {
$output->writeln(sprintf('<error>Job failed: %s</error>', $e->getMessage()));
// Wichtig: Status wird im Orchestrator gesetzt
$output->writeln(sprintf(
'<error>Job failed: %s</error>',
$e->getMessage()
));
return Command::FAILURE;
}
}