Răsfoiți Sursa

Added additional logging

Lacey Sanderson 10 ani în urmă
părinte
comite
6b66d8bce6
1 a modificat fișierele cu 12 adăugiri și 3 ștergeri
  1. 12 3
      tripal_daemon/TripalJobDaemon.inc

+ 12 - 3
tripal_daemon/TripalJobDaemon.inc

@@ -14,14 +14,23 @@ class TripalJobDaemon extends JobDaemon {
   protected function job() {
 
     // First check to see if there are any tripal jobs to be run
-    $num_waiting_jobs = db_query('SELECT count(*) as count FROM {tripal_jobs} j WHERE j.pid IS NULL AND j.end_time IS NULL')->fetchField();
+    $waiting_jobs = db_query("SELECT count(*) as count, array_to_string(array_agg(j.job_id ORDER BY j.priority ASC, j.job_id ASC),'|') as jobs FROM {tripal_jobs} j WHERE j.pid IS NULL AND j.end_time IS NULL")->fetchObject();
+    $num_waiting_jobs = $waiting_jobs->count;
+    $job_ids = explode('|', $waiting_jobs->jobs);
 
     // If there are then run them and log the output
     if ($num_waiting_jobs > 0) {
-      $this->log("$num_waiting_jobs Waiting Tripal Jobs... Running them now.");
+      $this->log("$num_waiting_jobs Waiting Tripal Jobs... Running waiting job(s) now.");
 
       // Launch all tripal jobs :) Yay for bootstrapping!!
-      tripal_launch_job();
+      foreach ($job_ids as $id) {
+        $this->log("Starting Job (ID=$id)","",1);
+        tripal_launch_job(FALSE, $id);
+
+        // Report job details
+        $job = db_query("SELECT j.* FROM {tripal_jobs} j WHERE j.job_id = :jid", array(':jid' => $id))->fetchObject();
+        $this->log("Job completed at ". date($job->end_time, 'd M Y H:i:s') . " with a status of '" . $job->status . "'","",1);
+      }
     }
     else {
       $this->log('There are no Tripal Jobs to run');