function drush_tripal_trp_rerun_job

3.x tripal.drush.inc drush_tripal_trp_rerun_job()

Executes jobs in the Tripal Jobs Queue.

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

Related topics

File

tripal/tripal.drush.inc, line 243
Contains function relating to drush-integration of this module.

Code

function drush_tripal_trp_rerun_job() {
  // 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');
  print date('Y-m-d H:i:s') . ": USER: '$user', UNAME: '$uname'\n";
  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;
  }

  $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);

  drush_tripal_set_user($username);
  $new_job_id = tripal_rerun_job($job_id, FALSE);

  drush_print("\n" . date('Y-m-d H:i:s'));
  if ($parallel) {
    drush_print("Tripal Job Launcher (in parallel)");
    drush_print("Running as user '$username'");
    drush_print("-------------------");
    tripal_launch_job($parallel, $new_job_id, $max_jobs, $single);
  }
  else {
    drush_print("Tripal Job Launcher");
    drush_print("Running as user '$username'");
    drush_print("-------------------");
    tripal_launch_job(0, $new_job_id, $max_jobs, $single);
  }

}