#!/usr/bin/env php bootstrapWorker(); $queue = $container->get(Queue::class); $worker = new Worker( $container, $queue, #new FileQueue(__DIR__ . '/src/Framework/CommandBus/storage/queue/'), $container->get(CommandBus::class), $container->get(ConsoleOutput::class), ); // Setup signal handlers using PCNTL service if available try { $pcntlService = $container->get(PcntlService::class); $pcntlService->registerSignal(Signal::SIGTERM, function () use ($worker) { $worker->stop(); }); $pcntlService->registerSignal(Signal::SIGINT, function () use ($worker) { $worker->stop(); }); } catch (\Throwable $e) { // Fallback to direct pcntl_signal if PCNTL service not available if (function_exists('pcntl_signal')) { pcntl_signal(SIGTERM, function () use ($worker) { $worker->stop(); }); pcntl_signal(SIGINT, function () use ($worker) { $worker->stop(); }); } } $worker->start(); /* $queue = new FileQueue(__DIR__ . '/src/Framework/CommandBus/storage/queue/'); error_log('Worker started'); error_log(__DIR__ . '/src/Framework/CommandBus/storage/queue'); #$commandBus = $container->get(CommandBus::class); #$commandBus->dispatch(new \App\Application\Newsletter\SignUp\SignupUserToNewsletter('Michael', 'mail')); #var_dump($queue); while (true) { $job = $queue->pop(); if ($job) { try { // Job verarbeiten #$commandBus->handle($job); error_log('handled: ' . $job::class); #(new JobProcessor())->handle($job); } catch (\Throwable $e) { // Fehler-Handling / Retry-Logik } } else { // Leerlauf-Pause, z.B. 100 ms usleep(100_000); } }*/