You are here

function elysia_cron_run_channel in Elysia Cron 6.2

Same name and namespace in other branches
  1. 7.2 elysia_cron.module \elysia_cron_run_channel()

Public function to execute all jobs in a channel

Parameters

$ignore_disable Run the channel (and all it's jobs) even if disabled:

$ignore_time Run channel (and all it's jobs) job even if not ready:

$ignore_running Run the channel (and all it's jobs) even if already running:

1 call to elysia_cron_run_channel()
drush_elysia_cron_run_wrapper in ./elysia_cron.drush.inc
A drush command callback.

File

./elysia_cron.module, line 1116

Code

function elysia_cron_run_channel($channel, $ignore_disable = false, $ignore_time = false, $ignore_running = false) {
  global $elysia_cron_settings_by_channel;
  elysia_cron_prepare_run(true);

  // Always $manual_run
  if ($execute = elysia_cron_lock_env()) {
    elysia_cron_initialize();
    $jobs = false;
    if (isset($elysia_cron_settings_by_channel[$channel])) {
      if ($ignore_disable || empty($elysia_cron_settings_by_channel[$channel]['#data']['disabled'])) {
        $jobs = elysia_cron_check_run_channel($channel, $ignore_disable, $ignore_time, $ignore_running);
        if ($jobs && count($jobs)) {

          // elysia_cron_internal_execute_channel calls elysia_cron_unlock_env
          elysia_cron_internal_execute_channel($channel, $jobs, $ignore_running);
        }
        else {
          elysia_cron_debug('Channel already running or no jobs ready to be executed, skipping');
        }
      }
      else {
        elysia_cron_warning('Channel is disabled, skipping');
      }
    }
    else {
      elysia_cron_warning('Channel not found, skipping');
    }
    if (!$jobs) {

      // No jobs should be executed, i must unlock cron semaphore
      elysia_cron_unlock_env();
    }
  }
  elysia_cron_unprepare_run(true);
  return $execute;
}