Cleanup events and stuff before processing job in worker
This commit is contained in:
@@ -23,7 +23,6 @@ class WorkerCommand extends BaseCommand
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->dispatcher->dispatch('app.bootstrap');
|
||||
$this->queueManager->listen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,4 +139,20 @@ class ActionManager extends Base
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all listeners for automated actions
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function removeEvents()
|
||||
{
|
||||
foreach ($this->dispatcher->getListeners() as $eventName => $listeners) {
|
||||
foreach ($listeners as $listener) {
|
||||
if (is_array($listener) && $listener[0] instanceof ActionBase) {
|
||||
$this->dispatcher->removeListener($eventName, $listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ class JobHandler extends Base
|
||||
|
||||
try {
|
||||
$className = $payload['class'];
|
||||
$this->memoryCache->flush();
|
||||
$this->prepareJobSession($payload['user_id']);
|
||||
$this->prepareJobEnvironment();
|
||||
|
||||
if (DEBUG) {
|
||||
$this->logger->debug(__METHOD__.' Received job => '.$className.' ('.getmypid().')');
|
||||
@@ -75,4 +75,16 @@ class JobHandler extends Base
|
||||
$this->userSession->initialize($user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush in-memory caching and specific events
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function prepareJobEnvironment()
|
||||
{
|
||||
$this->memoryCache->flush();
|
||||
$this->actionManager->removeEvents();
|
||||
$this->dispatcher->dispatch('app.bootstrap');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user