示例#1
0
 * Script to handle process queue jobs.
 */
set_time_limit(0);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
//_drush_bootstrap_drupal_full();
define('MAXIMUM_JOBS_TO_RUN', 1);
TextLogMessageTrimmer::$LOGGED_TEXT_LENGTH__MAXIMUM = 512 * 10;
// Make sure data is not getting updated:
// TODO - This  will be handled by server scripts.
$log_id = date('mdYHis');
LogHelper::log_notice("{$log_id}: Cron invoked for processing next job in queue.");
if (!QueueUtil::isJobsInProgress()) {
    LogHelper::log_notice("{$log_id}: No job is in progress. Getting next job.");
    try {
        $job_details = QueueUtil::getNextJob();
    } catch (Exception $claim_exception) {
        LogHelper::log_error("{$log_id}: Error while fetching job from queue: " . $claim_exception);
        return;
    }
    if ($job_details) {
        try {
            $job_id = $job_details['job_id'];
            LogHelper::log_notice("{$log_id}: Fetched next job from queue for job id:" . $job_details['job_id']);
            LogHelper::log_notice("{$log_id}: Claiming job from queue:" . $job_id);
            $job_claimed = QueueUtil::claimJob($job_id);
            if ($job_claimed) {
                LogHelper::log_notice("{$log_id}: Job {$job_id} is claimed for processing.");
                LogHelper::log_notice("{$log_id}: Started processing job {$job_id}.");
                $queue_job = new QueueJob($job_details);
                $queue_job->setLogId($log_id);