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);
if (!$job) {
$output->writeln('IngestJob not found.');
return Command::FAILURE;
}
// 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('Job already finished.');
return Command::SUCCESS;
}
try {
$output->writeln(sprintf(
'Running ingest job %s (type: %s)...',
(string) $job->getId(),
$job->getType()
));
$this->orchestrator->runExistingJob($job, $dryRun);
$output->writeln('Job completed successfully.');
return Command::SUCCESS;
} catch (\Throwable $e) {
// Wichtig: Status wird im Orchestrator gesetzt
$output->writeln(sprintf(
'Job failed: %s',
$e->getMessage()
));
return Command::FAILURE;
}
}
}