You are here

function elysia_cron_check_run_channel in Elysia Cron 7.2

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

Check if the channel is idle (not running, or stuck). If so set returns available jobs.

Return value

array of jobs ready to be executed, or FALSE if channel is running

2 calls to elysia_cron_check_run_channel()
elysia_cron_run_available_channel in ./elysia_cron.module
Find an idle channel (not running, or stuck). If found one, set it as running and returns available jobs.
elysia_cron_run_channel in ./elysia_cron.module
Public function to execute all jobs in a channel.

File

./elysia_cron.module, line 1521

Code

function elysia_cron_check_run_channel($channel, $ignore_disable = FALSE, $ignore_time = FALSE, $ignore_running = FALSE) {
  global $_elysia_cron_settings_by_channel;
  $jobs = FALSE;
  $stuck_time = variable_get('elysia_cron_stuck_time', 3600);
  $sem = elysia_cron_is_channel_running($channel);
  if ($sem && time() - $sem > $stuck_time) {
    elysia_cron_set_channel_running($channel, 0);
    $last_job = elysia_cron_execute_aborted($channel);
    unset($sem);
    elysia_cron_error('Cron channel (%channel) has been running for more than an %stuck_time secs and is most likely stuck. Last job executed: %job', array(
      '%channel' => $channel,
      '%stuck_time' => $stuck_time,
      '%job' => $last_job,
    ), TRUE);
  }
  if (($ignore_running || empty($sem)) && ($ignore_disable || !$_elysia_cron_settings_by_channel[$channel]['#data']['disabled'])) {
    $jobs = elysia_cron_active_jobs($channel, $ignore_disable, $ignore_time);
  }
  return $jobs;
}