Files
proton/framework/Console/Commands/WorkerCommand.php
T
2026-09-12 23:55:44 +03:00

41 lines
912 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace Rsgrinko\Proton\Console\Commands;
use Rsgrinko\Proton\Console\Command;
use Rsgrinko\Proton\Queue\Queue;
use Rsgrinko\Proton\Queue\Worker;
/**
* воркер очереди.
*/
final class WorkerCommand extends Command
{
public function name(): string
{
return 'worker';
}
public function description(): string
{
return 'разбирать очередь задач и вести расписание';
}
public function usage(): string
{
return 'worker [--once] [--queue=default]';
}
public function run(): int
{
$queue = (string) $this->option('queue', Queue::DEFAULT_QUEUE);
$result = (new Worker($queue))->run($this->hasOption('once'));
$this->line('Выполнено: ' . $result['done'] . ', с ошибкой: ' . $result['failed']);
return 0;
}
}