You are here

function ultimate_cron_init in Ultimate Cron 6

Same name and namespace in other branches
  1. 8 ultimate_cron.module \ultimate_cron_init()
  2. 7.2 ultimate_cron.module \ultimate_cron_init()
  3. 7 ultimate_cron.module \ultimate_cron_init()

Implements hook_init().

File

./ultimate_cron.module, line 499
@todo Add filter on overview page. @todo Add log view (with graph). @todo Make proper markup for overview page. @todo Refactor drush stuff, too many intimate relations with Background Process @todo Refactor Cron % offset stuff. Too mixed up and…

Code

function ultimate_cron_init() {

  // No need for hocus pocus and poorman until site is installed.
  if (variable_get('install_task', FALSE) != 'done') {
    return;
  }
  global $conf;
  if (basename(getenv('SCRIPT_NAME')) == 'cron.php') {
    if (!lock_acquire('cron', 120.0)) {

      // watchdog('ultimate_cron', 'Could not acquire lock, cron already running', array(), WATCHDOG_WARNING);
      exit;
    }

    // Get rid of foolish non-atomic cron semaphore, as we now have a proper lock.
    unset($conf['cron_semaphore']);
  }
  $name = 'cron_last';
  if ($value = db_result(db_query("SELECT value FROM {variable} WHERE name = '%s'", $name))) {
    $value = unserialize($value);
  }
  global $conf;
  $conf['cron_last'] = $value;
  ultimate_cron_trigger_poorman();
}