mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Reverted changes added by commit be7ea871be
This commit is contained in:
@@ -12,11 +12,3 @@ $config['job_type_permissions_white_list'] = array(
|
||||
'SAPPayment' => 'developer:rw'
|
||||
);
|
||||
|
||||
// List of schedulers that can be run by the scheduler
|
||||
$config['job_schedulers_list'] = array( // Controllers
|
||||
'extensions/FHC-Core-SAP/JQMScheduler' => array( // Methods
|
||||
'newUsers',
|
||||
'updateUsers'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This controller is a job that exposes the start method
|
||||
* If it is called it will look into the configuration file to get all the extensions
|
||||
* that need to place jobs into the jobs queue
|
||||
*/
|
||||
class JobsQueueScheduler extends JQW_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function schedule()
|
||||
{
|
||||
$this->logInfo('Scheduler started');
|
||||
|
||||
$schedulerResult = $this->jobsqueuelib->schedule();
|
||||
|
||||
// If error occurred then log it
|
||||
if (isError($schedulerResult)) $this->logError(getError($schedulerResult));
|
||||
|
||||
// If non blocking errors occurred log them
|
||||
if (hasData($schedulerResult) && !isEmptyArray(getData($schedulerResult)))
|
||||
{
|
||||
foreach (getData($schedulerResult) as $nonBlockingError)
|
||||
{
|
||||
$this->logWarning($nonBlockingError);
|
||||
}
|
||||
}
|
||||
|
||||
$this->logInfo('Scheduler ended');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,6 @@ class JobsQueueLib
|
||||
const PROPERTY_END_TIME = 'endtime';
|
||||
const PROPERTY_ERROR = 'error';
|
||||
|
||||
// Config entries
|
||||
const JOB_SCHEDULERS_LIST = 'job_schedulers_list';
|
||||
|
||||
private $_ci; // CI instance
|
||||
|
||||
/**
|
||||
@@ -42,9 +39,6 @@ class JobsQueueLib
|
||||
$this->_ci->load->model('system/JobTypes_model', 'JobTypesModel');
|
||||
$this->_ci->load->model('system/JobStatuses_model', 'JobStatusesModel');
|
||||
$this->_ci->load->model('system/JobTriggers_model', 'JobTriggersModel');
|
||||
|
||||
// Loads configs
|
||||
$this->_ci->config->load('jqm');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
@@ -202,68 +196,6 @@ class JobsQueueLib
|
||||
return success($results); // otherwise return results in a success object
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the job object structure when needed for insert
|
||||
*/
|
||||
public function schedule()
|
||||
{
|
||||
// An array of non blocking errors
|
||||
$nonBlockingErrorsArray = array();
|
||||
|
||||
// Get the all the configured schedulers
|
||||
$schedulers = $this->_ci->config->item(self::JOB_SCHEDULERS_LIST);
|
||||
|
||||
// If is it empty then non blocking error
|
||||
if (isEmptyArray($schedulers)) return success('No schedulers where configured');
|
||||
|
||||
// For each scheduler
|
||||
foreach ($schedulers as $controller => $methods)
|
||||
{
|
||||
// If the specified controller does not exist
|
||||
if (!file_exists(APPPATH.'controllers/'.$controller.'.php'))
|
||||
{
|
||||
$nonBlockingErrorsArray[] = 'The controller '.$controller.' does not exist';
|
||||
}
|
||||
else // try to call it
|
||||
{
|
||||
$arrayMethods = array();
|
||||
|
||||
// If methods is a string
|
||||
if (is_string($methods))
|
||||
{
|
||||
$arrayMethods[] = $methods;
|
||||
}
|
||||
elseif (is_array($methods)) // otherwise if is an array
|
||||
{
|
||||
$arrayMethods = $methods;
|
||||
}
|
||||
|
||||
// For eache configured method
|
||||
foreach ($arrayMethods as $method)
|
||||
{
|
||||
// Generate command string
|
||||
$command = sprintf(
|
||||
'php %s/../index.ci.php %s %s >> %s/logs/scheduler-%s-%s.log 2>>%s/logs/scheduler-error-%s-%s.log &',
|
||||
APPPATH,
|
||||
$controller,
|
||||
$method,
|
||||
APPPATH,
|
||||
str_replace('/', '-', $controller),
|
||||
date('Y-m-d'),
|
||||
APPPATH,
|
||||
str_replace('/', '-', $controller),
|
||||
date('Y-m-d')
|
||||
);
|
||||
|
||||
// Execute command string
|
||||
@shell_exec($command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success($nonBlockingErrorsArray);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
|
||||
Reference in New Issue
Block a user