-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
run queue
Expected behavior
Queue worker started for queue 'database'...
> Using database connection for queue...
------------------------
Leaf MVC TypeError: Cannot access offset of type string on string in file dir/vendor/leafs/queue/src/Queue/Commands/QueueWorkCommand.php on line 27
Stack trace:
1. TypeError->() dir/vendor/leafs/queue/src/Queue/Commands/QueueWorkCommand.php:27
2. Leaf\Queue\Commands\QueueWorkCommand->handle() dir/vendor/leafs/sprout/src/Sprout/Command.php:235
3. Leaf\Sprout\Command->call() dir/vendor/leafs/sprout/src/Sprout/App.php:328
4. Leaf\Sprout\App->run() dir/vendor/leafs/mvc-core/src/Core.php:502
5. Leaf\Core->loadConsole() dir/leaf:51Fix QueueWorkCommand.php
<?php
namespace Leaf\Queue\Commands;
use Leaf\Sprout\Command;
use Throwable;
class QueueWorkCommand extends Command
{
protected $queueConfig;
protected $signature = 'queue:work
{--queue? : The queue you want to run}';
protected $description = 'Start your queue worker';
protected function handle()
{
$this->queueConfig = MvcConfig('queue');
$queue = $this->option('queue')
?? $this->queueConfig['default']
?? null;
if (!$queue || !isset($this->queueConfig['connections'][$queue])) {
$this->writeln("<error>Queue '{$queue}' not found</error>");
return 1;
}
$connection = $this->queueConfig['connections'][$queue];
$this->writeln("Queue worker started for queue '{$queue}'...");
while (true) {
try {
(new \Leaf\Worker())
->queue($connection)
->scheduler($connection)
->run();
} catch (Throwable $e) {
// Ignore missing job class errors
if (
str_contains($e->getMessage(), 'Class "') &&
str_contains($e->getMessage(), '" not found')
) {
$this->writeln(
"<comment>[SKIPPED]</comment> {$e->getMessage()}"
);
// Continue worker loop instead of crashing
sleep(1);
continue;
}
// Re-throw everything else
throw $e;
}
}
}
}Metadata
Metadata
Assignees
Labels
No labels