mirror of
https://github.com/flarum/framework.git
synced 2025-04-25 14:14:03 +08:00
feat: Restart the queue worker after cache clearing, ext enable/disable, save settings (#3565)
* Add queue restarter * Update framework/core/src/Queue/QueueRestarter.php
This commit is contained in:
parent
7147d39975
commit
da855c654e
57
framework/core/src/Queue/QueueRestarter.php
Normal file
57
framework/core/src/Queue/QueueRestarter.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* For detailed copyright and license information, please view the
|
||||||
|
* LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Queue;
|
||||||
|
|
||||||
|
use Flarum\Extension\Event\Disabled;
|
||||||
|
use Flarum\Extension\Event\Enabled;
|
||||||
|
use Flarum\Foundation\Event\ClearingCache;
|
||||||
|
use Flarum\Settings\Event\Saved;
|
||||||
|
use Illuminate\Contracts\Container\Container;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
use Illuminate\Queue\Console\RestartCommand;
|
||||||
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
|
use Symfony\Component\Console\Output\NullOutput;
|
||||||
|
|
||||||
|
class QueueRestarter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Container
|
||||||
|
*/
|
||||||
|
protected $container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var RestartCommand
|
||||||
|
*/
|
||||||
|
protected $command;
|
||||||
|
|
||||||
|
public function __construct(Container $container, RestartCommand $command)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function subscribe(Dispatcher $events)
|
||||||
|
{
|
||||||
|
$events->listen([
|
||||||
|
ClearingCache::class, Saved::class,
|
||||||
|
Enabled::class, Disabled::class
|
||||||
|
], [$this, 'restart']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function restart()
|
||||||
|
{
|
||||||
|
$this->command->setLaravel($this->container);
|
||||||
|
|
||||||
|
$this->command->run(
|
||||||
|
new ArrayInput([]),
|
||||||
|
new NullOutput
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -161,5 +161,7 @@ class QueueServiceProvider extends AbstractServiceProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$events->subscribe(QueueRestarter::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user