LogLibJob->setConfigs( array( 'dbExecuteUser' => get_class($this), 'requestId' => 'LRT' ) ); // Loads LongRunTaskLib library $this->load->library('LongRunTaskLib'); } /** * Executes all the new LRTs */ public function execEmAll() { $this->logInfo('Execute long run tasks started'); // Get all the LRTs that is possible to execute now $lrtsResult = $this->longruntasklib->getNewLRTs(); // If an error occurred then return it if (isError($lrtsResult)) return $lrtsResult; if (hasData($lrtsResult)) { // For each LRT foreach (getData($lrtsResult) as $lrt) { // Execute the task $executeLrtResult = $this->longruntasklib->executeLrt($lrt); if (isError($executeLrtResult)) $this->logError($executeLrtResult); } } $this->logInfo('Execute long run tasks ended'); } /** * Kills all the hanging LRTs */ public function killHangingLRTs() { $this->logInfo('Kill hanging LRTs started'); // Get all the LRTs that is possible to execute now $lrtsResult = $this->longruntasklib->getHangingLRTs(); // If an error occurred then return it if (isError($lrtsResult)) return $lrtsResult; if (hasData($lrtsResult)) { // For each LRT foreach (getData($lrtsResult) as $lrt) { // Kill the task $killLrtResult = $this->longruntasklib->killLrt($lrt); if (isError($killLrtResult)) $this->logError($killLrtResult); } } $this->logInfo('Kill hanging LRTs ended'); } /** * */ public function checkExecution() { $this->logInfo('Check execution long run tasks started'); // Get the related LRT data from the queue $lrtsResult = $this->longruntasklib->getRunningLRTs(); // If an error occurred then return it if (isError($lrtsResult)) return $lrtsResult; // If there are running LRTs if (hasData($lrtsResult)) { // For each LRT foreach (getData($lrtsResult) as $lrt) { // Check the LRT execution $checkExecutionResult = $this->longruntasklib->checkExecution($lrt); if (isError($checkExecutionResult)) $this->logError($checkExecutionResult); } } $this->logInfo('Check execution long run tasks ended'); } }