TripalJobDaemon.inc 862 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * This is the main class for a Job Daemon.
  4. *
  5. * A Daemon is created by running run.php where an instance of this class is created
  6. */
  7. class TripalJobDaemon extends JobDaemon {
  8. /**
  9. * Implements JobDaemon::job() function
  10. * This gets executed once per loop iteration
  11. */
  12. protected function job() {
  13. // First check to see if there are any tripal jobs to be run
  14. $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();
  15. // If there are then run them and log the output
  16. if ($num_waiting_jobs > 0) {
  17. $this->log("$num_waiting_jobs Waiting Tripal Jobs... Running them now.");
  18. // Launch all tripal jobs :) Yay for bootstrapping!!
  19. tripal_launch_job();
  20. }
  21. else {
  22. $this->log('There are no Tripal Jobs to run');
  23. }
  24. }
  25. }