You are here

function elysia_cron_internal_execute_channel in Elysia Cron 7.2

Same name and namespace in other branches
  1. 6.2 elysia_cron.module \elysia_cron_internal_execute_channel()

Internal function to execute all jobs in a channel.

Function elysia_cron_lock_env() must be called BEFORE calling this method.

2 calls to elysia_cron_internal_execute_channel()
elysia_cron_run in ./elysia_cron.module
Public function to invoke a complete cron_run.
elysia_cron_run_channel in ./elysia_cron.module
Public function to execute all jobs in a channel.

File

./elysia_cron.module, line 1428

Code

function elysia_cron_internal_execute_channel($channel, $jobs, $ignore_running = FALSE) {
  global $_elysia_cron_current_channel, $_cron_completed, $_cron_completed_time;
  elysia_cron_debug('Cron channel %channel run started.', array(
    '%channel' => $channel,
  ));
  $_elysia_cron_current_channel = $channel;
  elysia_cron_set($_elysia_cron_current_channel, TRUE, array(
    'running' => time(),
    'last_run' => time(),
  ));

  // Register shutdown callback.
  register_shutdown_function('elysia_cron_internal_execute_channel_cleanup');

  // Now I can unlock cron semaphore.
  elysia_cron_unlock_env();
  foreach ($jobs as $job) {
    if ($ignore_running || !elysia_cron_check_run_job($job)) {
      elysia_cron_internal_execute_job($job);
    }
  }
  $_cron_completed = TRUE;
  $_cron_completed_time = time();

  // Cron is really completed after shutdown functions.
  register_shutdown_function('elysia_cron_internal_execute_channel_completed');
}