Cleanup events and stuff before processing job in worker

This commit is contained in:
Frederic Guillot
2016-07-31 11:28:33 -04:00
parent 92ac133d23
commit 92a5a0f860
5 changed files with 71 additions and 7 deletions

View File

@@ -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');
}
}