tripal_daemon_script.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * This is the script that is actually Daemonized.
  4. * Expected to be run via Drush tripal-jobs-daemon
  5. */
  6. // Get Command-line Variables
  7. parse_str(implode('&', array_slice($argv, 1)), $args);
  8. $action = $argv[1];
  9. if (!$action) {
  10. die('You need to specify what you want the Daemon to do. This should be one of: start, stop, restart, status, show-log');
  11. }
  12. require_once $args['module_path'] . '/classes/TripalJobDaemon.inc';
  13. $Daemon = new TripalJobDaemon($args);
  14. print "\nTripal Jobs Daemon\n".str_repeat("=",60)."\n";
  15. print "Memory Threshold: " . ($Daemon->get_memory_threshold() * 100) . "%\n";
  16. print "Wait Time: ". $Daemon->get_wait_time() . " seconds\n";
  17. print "Log File: " . $Daemon->log_filename . "\n";
  18. print "\n";
  19. // Check that the action is valid and then execute it
  20. // Everything else is taken case of by the object :)
  21. $action = strtolower($action);
  22. if (method_exists($Daemon, $action)) {
  23. $Daemon->{$action}();
  24. }
  25. else {
  26. die("ERROR: Unable to $action the daemon. This action is not recognized; instead try one of 'start', 'stop', 'restart', 'status' or 'log'.\n\n");
  27. }