Abdullah Almsaeed 8 жил өмнө
parent
commit
2ecc757cc8

+ 20 - 0
tripal_core/api/tripal_core.jobs.api.inc

@@ -277,6 +277,26 @@ function tripal_cancel_job($job_id, $redirect = TRUE) {
   }
 }
 
+
+function tripal_execute_job($job_id, $redirect = TRUE) {
+  global $user;
+
+  $sql = "SELECT * FROM {tripal_jobs} WHERE job_id = :job_id";
+  $results = db_query($sql, array(':job_id' => $job_id));
+  $job = $results->fetchObject();
+
+  // set the end time for this job
+  if ($job->start_time == 0 && $job->end_time == 0) {
+    exec("drush trp-run-jobs --username=".$user->name." --root=".DRUPAL_ROOT."");
+  }
+  else {
+    drupal_set_message(t("Job %job_id cannot be executed. It is in progress or has finished.", array('%job_id' => $job_id)));
+  }
+  if ($redirect) {
+    drupal_goto("admin/tripal/tripal_jobs/view/$job_id");
+  }
+}
+
 /**
  * A function used to manually launch all queued tripal jobs
  *

+ 10 - 0
tripal_core/tripal_core.module

@@ -211,6 +211,16 @@ function tripal_core_menu() {
     'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
   );
+
+  $items['admin/tripal/tripal_jobs/execute/%'] = array(
+    'title' => 'Jobs',
+    'description' => t('Execute an existing job'),
+    'page callback' => 'tripal_execute_job',
+    'page arguments' => array(4),
+    'access arguments' => array('administer tripal'),
+    'type' => MENU_CALLBACK,
+  );
+
   $items['admin/tripal/tripal_jobs/rerun/%'] = array(
     'title' => 'Jobs',
     'description' => t('Re-run an existing job.'),