function lassie_start

6.x lassie.module lassie_start($job_machine_name, $hours = 2, $emails = "")

Set a new job for Lassie to watch.

Parameters

$job_machine_name - The machine name of this job. Must be alphanumeric + underscore. Ex: job_123:

$hours - must be integer or a warning will be logged and displayed via fpm().:

$emails - comma separated listed of email addresses to notify if the job fails to finish.:

File

modules/lassie/lassie.module, line 26
This is the primary module file for the lassie module.

Code

function lassie_start($job_machine_name, $hours = 2, $emails = "") {
  global $user;

  if (!is_int($hours)) {
    fpm("WARNING: hours ($hours) supplied to lassie_start() function is not an integer.  Casting to int.");
    fpm(debug_backtrace());
    watchdog('lassie', "WARNING: hours ($hours) supplied to lassie_start() function is not integer.  Casting to int. Backtrace: <pre>" . print_r(debug_backtrace(), TRUE) . "</pre>", array(), WATCHDOG_ERROR);
    $hours = intval($hours);
  }

  $job_machine_name = lassie_get_machine_name($job_machine_name);

  $data = array(
    'start' => time(),
    'hours' => $hours,
    'expires' => strtotime("NOW + $hours HOURS"),
    'emails' => $emails,
    'user_uid' => $user->uid,
  );


  variable_set('lassie_job__' . $job_machine_name, $data);

  watchdog('lassie', t("Beginning new job: ") . $job_machine_name . ". " . print_r($data, TRUE));

}