function drush_tripal_core_trp_run_jobs

2.x tripal_core.drush.inc drush_tripal_core_trp_run_jobs()

Executes jobs in the Tripal Jobs Queue.

Executed when 'drush trp-run-job' is called.

Related topics

File

tripal_core/tripal_core.drush.inc, line 301
Contains function relating to drush-integration of this module.

Code

function drush_tripal_core_trp_run_jobs() {
  $parallel = drush_get_option('parallel');
  $job_id = drush_get_option('job_id');
  $max_jobs = drush_get_option('max_jobs', -1);
  $single = drush_get_option('single', 0);

  // Unfortunately later versions of Drush use the '--user' argument which
  // makes it incompatible with how Tripal was using it.  For backwards
  // compatabiliy we will accept --user with a non numeric value only. The
  // numeric value should be for Drush. Tripal will instead use the
  // --username argument for the fture.
  $user = drush_get_option('user');
  $uname = drush_get_option('username');
  if ($user and is_numeric($user)) {
  }
  elseif ($user) {
    print "\nNOTE: Use of the --user argument is deprecated as it conflicts with the --user argument of Drush 7.x. Please now use --username instead.\n\n";
    $username = $user;
  }
  if ($uname) {
    $username = $uname;
  }

  drush_tripal_core_set_user($username);

  drush_print("\n" . date('Y-m-d H:i:s'));
  if ($parallel) {
    drush_print("Tripal Job Launcher (in parallel)");
    if ($max_jobs !== -1) {
      drush_print("Maximum number of jobs is " . $max_jobs);
    }
    drush_print("Running as user '$username'");
    drush_print("-------------------");
    tripal_launch_job($parallel, $job_id, $max_jobs, $single);
  }
  else {
    drush_print("Tripal Job Launcher");
    drush_print("Running as user '$username'");
    drush_print("-------------------");
    tripal_launch_job(0, $job_id, $max_jobs, $single);
  }
}