Fixes the queue listen command. We might need to rectify this implementation before stable.

This commit is contained in:
Daniël Klabbers 2019-09-11 11:42:52 +02:00
parent 923eea1cd8
commit 58e1c6cd99
3 changed files with 35 additions and 3 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace Flarum\Queue\Console;
use Illuminate\Queue\Listener;
class ListenCommand extends \Illuminate\Queue\Console\ListenCommand
{
public function __construct(Listener $listener)
{
parent::__construct($listener);
$this->addOption('env');
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Flarum\Queue;
use Illuminate\Queue\ListenerOptions;
class Listener extends \Illuminate\Queue\Listener
{
protected function addEnvironment($command, ListenerOptions $options)
{
$options->environment = null;
return $command;
}
}

View File

@ -18,8 +18,8 @@ use Illuminate\Contracts\Queue\Factory;
use Illuminate\Queue\Connectors\ConnectorInterface; use Illuminate\Queue\Connectors\ConnectorInterface;
use Illuminate\Queue\Console as Commands; use Illuminate\Queue\Console as Commands;
use Illuminate\Queue\Failed\NullFailedJobProvider; use Illuminate\Queue\Failed\NullFailedJobProvider;
use Illuminate\Queue\Listener;
use Illuminate\Queue\SyncQueue; use Illuminate\Queue\SyncQueue;
use Illuminate\Queue\Listener as QueueListener;
use Illuminate\Queue\Worker; use Illuminate\Queue\Worker;
class QueueServiceProvider extends AbstractServiceProvider class QueueServiceProvider extends AbstractServiceProvider
@ -27,7 +27,7 @@ class QueueServiceProvider extends AbstractServiceProvider
protected $commands = [ protected $commands = [
Commands\FlushFailedCommand::class, Commands\FlushFailedCommand::class,
Commands\ForgetFailedCommand::class, Commands\ForgetFailedCommand::class,
// Commands\ListenCommand::class, Console\ListenCommand::class,
Commands\ListFailedCommand::class, Commands\ListFailedCommand::class,
// Commands\RestartCommand::class, // Commands\RestartCommand::class,
Commands\RetryCommand::class, Commands\RetryCommand::class,
@ -36,6 +36,8 @@ class QueueServiceProvider extends AbstractServiceProvider
public function register() public function register()
{ {
define('ARTISAN_BINARY', 'flarum');
// Register a simple connection factory that always returns the same // Register a simple connection factory that always returns the same
// connection, as that is enough for our purposes. // connection, as that is enough for our purposes.
$this->app->singleton(Factory::class, function () { $this->app->singleton(Factory::class, function () {
@ -65,7 +67,7 @@ class QueueServiceProvider extends AbstractServiceProvider
); );
}); });
$this->app->singleton(Listener::class, function ($app) { $this->app->singleton(QueueListener::class, function ($app) {
return new Listener($app->basePath()); return new Listener($app->basePath());
}); });