فهرست منبع

Added functionality to launch a single job using drush using the job_id

spficklin 12 سال پیش
والد
کامیت
537315c08b
2فایلهای تغییر یافته به همراه24 افزوده شده و 11 حذف شده
  1. 18 4
      tripal_core/includes/jobs.php
  2. 6 7
      tripal_core/tripal_core.drush.inc

+ 18 - 4
tripal_core/includes/jobs.php

@@ -271,9 +271,16 @@ function tripal_jobs_get_submit_date($job) {
  * @param $do_parallel
  *   A boolean indicating whether jobs should be attempted to run in parallel
  *
+ * @param $job_id
+ *   To launch a specific job provide the job id.  This option should be
+ *   used sparingly as the jobs queue managment system should launch jobs
+ *   based on order and priority.  However there are times when a specific
+ *   job needs to be launched and this argument will allow it.  Only jobs 
+ *   which have not been run previously will run.
+ *
  * @ingroup tripal_jobs_api
  */
-function tripal_jobs_launch($do_parallel = 0) {
+function tripal_jobs_launch($do_parallel = 0, $job_id = NULL) {
 
   // first check if any jobs are currently running
   // if they are, don't continue, we don't want to have
@@ -284,9 +291,16 @@ function tripal_jobs_launch($do_parallel = 0) {
 
   // get all jobs that have not started and order them such that
   // they are processed in a FIFO manner.
-  $sql =  "SELECT * FROM {tripal_jobs} TJ ".
-         "WHERE TJ.start_time IS NULL and TJ.end_time IS NULL ".
-         "ORDER BY priority ASC,job_id ASC";
+  if ($job_id) {
+    $sql =  "SELECT * FROM {tripal_jobs} TJ ".
+            "WHERE TJ.start_time IS NULL and TJ.end_time IS NULL and TJ.job_id = %d ".
+            "ORDER BY priority ASC,job_id ASC";
+  } 
+  else {
+    $sql =  "SELECT * FROM {tripal_jobs} TJ ".
+            "WHERE TJ.start_time IS NULL and TJ.end_time IS NULL ".
+            "ORDER BY priority ASC,job_id ASC";
+  }
   $job_res = db_query($sql);
   while ($job = db_fetch_object($job_res)) {
     // set the start time for this job

+ 6 - 7
tripal_core/tripal_core.drush.inc

@@ -58,16 +58,14 @@ function tripal_core_drush_command() {
   $items['tripal-launch-jobs'] = array(
     // used by drush help
     'description' => dt('Lauches any jobs waiting in the queue.'),
-    'arguments' => array(
-      'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
-    ),
     'examples' => array(
       'Normal Job' => 'drush tripal-launch-jobs',
       'Parallel Job' => 'drush tripal-launch-jobs --parallel=1'
     ),
     // supply options
     'options' => array(
-      'parallel',
+      'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
+      'job_id' => dt('Provide a job_id to run a specific job. Only jobs that have not been run already can be used'),      
     ),
     'aliases' => array('trpjob-run')
   );
@@ -81,15 +79,16 @@ function tripal_core_drush_command() {
  */
 function drush_tripal_core_tripal_launch_jobs() {
   $parallel = drush_get_option('parallel');
+  $job_id = drush_get_option('job_id');
   if ($parallel) {
     print "Tripal Job Launcher (in parallel)\n";
     print "-------------------\n";
-    tripal_jobs_launch($parallel);
+    tripal_jobs_launch($parallel,$job_id);
   }
   else {
     print "Tripal Job Launcher\n";
     print "-------------------\n";
-    tripal_jobs_launch();
+    tripal_jobs_launch(0,$job_id);
   }
 }
 
@@ -158,4 +157,4 @@ function drush_tripal_core_tripal_update_mview() {
   else {
     drush_set_error('Update failed.');
   }
-}
+}