Skip to content

Commit

Permalink
fix: don't replace command, just update it
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Nov 28, 2023
1 parent ecf17ff commit 86c0358
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
2 changes: 1 addition & 1 deletion extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

(new Extend\Console())
->command(Console\DatabaseWorkCommand::class)
->schedule('queue:work:db --stop-when-empty', function (Event $e) {
->schedule('queue:work --stop-when-empty', function (Event $e) {
$e->everyMinute();
}),

Expand Down
18 changes: 0 additions & 18 deletions src/Console/DatabaseWorkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,6 @@ class DatabaseWorkCommand extends \Flarum\Queue\Console\WorkCommand
{
protected $settings;

protected $signature = 'queue:work:db
{connection? : The name of the queue connection to work}
{--name=default : The name of the worker}
{--queue= : The names of the queues to work}
{--daemon : Run the worker in daemon mode (Deprecated)}
{--once : Only process the next job on the queue}
{--stop-when-empty : Stop when the queue is empty}
{--delay=0 : The number of seconds to delay failed jobs (Deprecated)}
{--backoff=0 : The number of seconds to wait before retrying a job that encountered an uncaught exception}
{--max-jobs=0 : The number of jobs to process before stopping}
{--max-time=0 : The maximum number of seconds the worker should run}
{--force : Force the worker to run even in maintenance mode}
{--memory=128 : The memory limit in megabytes}
{--sleep=3 : Number of seconds to sleep when no job is available}
{--rest=0 : Number of seconds to rest between jobs}
{--timeout=60 : The number of seconds a child process can run}
{--tries=1 : Number of times to attempt a job before logging it failed}';

public function __construct(Worker $worker, Cache $cache, SettingsRepositoryInterface $settings)
{
parent::__construct($worker, $cache);
Expand Down
22 changes: 11 additions & 11 deletions src/Provider/DatabaseQueueProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ class DatabaseQueueProvider extends AbstractServiceProvider
{
public function register()
{
$this->container->extend('flarum.console.commands', function (array $commands) {
$key = array_search(WorkCommand::class, $commands);

// If found, remove the command from the array
if ($key !== false) {
unset($commands[$key]);
}

return $commands;
});

$this->container->bind('flarum.queue.connection', function (Container $container) {
$queue = new Queue(
$container->make('db.connection'),
Expand All @@ -56,5 +45,16 @@ public function register()
'queue_failed_jobs'
);
});

$this->container->extend('flarum.console.commands', function (array $commands) {
$key = array_search(WorkCommand::class, $commands);

// If found, remove the command from the array
if ($key !== false) {
unset($commands[$key]);
}

return $commands;
});
}
}

0 comments on commit 86c0358

Please sign in to comment.