diff --git a/src/Cron/MeilisearchIndexCron.php b/src/Cron/MeilisearchIndexCron.php deleted file mode 100644 index faf71b7..0000000 --- a/src/Cron/MeilisearchIndexCron.php +++ /dev/null @@ -1,89 +0,0 @@ -logFile = $this->projectDir . '/var/logs/meilisearch_bundle.log'; - } - - public function __invoke(): void - { - $this->framework->initialize(); - - $this->log('=== CRON START ==='); - - // 1) Cleanup - $this->runStep( - 'meilisearch:files:cleanup', - 'meilisearch:files:cleanup' - ); - - // 2) Contao Crawl - $this->runStep( - 'contao:crawl', - 'contao:crawl' - ); - - // 3) Meilisearch Index - $this->runStep( - 'meilisearch:index', - 'meilisearch:index' - ); - - $this->log('=== CRON END ==='); - } - - /** - * Führt einen Console-Command aus und loggt sauber Start/Ende - */ - private function runStep(string $command, string $label): void - { - $this->log($label . ' gestartet'); - - $process = new Process([ - PHP_BINARY, - $this->projectDir . '/vendor/bin/contao-console', - ...explode(' ', $command), - ]); - - $process->setTimeout(null); - $process->run(); - - if (!$process->isSuccessful()) { - $this->log( - $label . ' FEHLGESCHLAGEN', - $process->getErrorOutput() ?: 'Unbekannter Fehler' - ); - - // ❌ Abbruch – Folgeschritte NICHT ausführen - return; - } - - $this->log($label . ' erfolgreich beendet'); - } - - /** - * Schreibt eine Logzeile mit Zeitstempel - */ - private function log(string $message, string $details = ''): void - { - $line = sprintf( - "[%s] %s%s\n", - date('Y-m-d H:i:s'), - $message, - $details ? ' | ' . trim($details) : '' - ); - - file_put_contents($this->logFile, $line, FILE_APPEND); - } -} \ No newline at end of file diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index b4e4b9e..79ae9db 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -3,7 +3,7 @@ services: Psr\Container\ContainerInterface: '@service_container' MummertMedia\ContaoMeilisearchBundle\: - resource: '../../{Command,Cron,EventListener,Service}' + resource: '../../{Command,EventListener,Service}' autowire: true autoconfigure: true @@ -19,12 +19,6 @@ services: tags: - { name: contao.hook, hook: indexPage, method: onIndexPage } - MummertMedia\ContaoMeilisearchBundle\Cron\MeilisearchIndexCron: - autowire: true - autoconfigure: false - tags: - - { name: contao.cron, interval: daily, method: __invoke } - MummertMedia\ContaoMeilisearchBundle\Controller\FrontendModule\MeilisearchSearchController: autowire: true autoconfigure: false