tripal_daemon_script.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. require_once 'classes/TripalDaemon.inc';
  3. /**
  4. * This is the script that is actually Daemonized.
  5. *
  6. * Arguments expected to be passed to this script:
  7. * - action: One of 'start','stop','restart',status','show-log'. Meant to indicate what
  8. * you want the daemon to do.
  9. * - log_file: the full path & filename of the log file. If it doesn't exist this script will
  10. * create it.
  11. */
  12. // Get Command-line Variables
  13. parse_str(implode('&', array_slice($argv, 1)), $args);
  14. $action = $argv[1];
  15. if (!$action) {
  16. die('You need to specify what you want the Daemon to do. This should be one of: start, stop, restart, status, show-log');
  17. }
  18. $Daemon = new TripalJobDaemon($args);
  19. print "\nTripal Jobs Daemon\n".str_repeat("=",60)."\n";
  20. print "Memory Threshold: " . ($Daemon->get_memory_threshold() * 100) . "%\n";
  21. print "Wait Time: ". $Daemon->get_wait_time() . " seconds\n";
  22. print "\n";
  23. // Check that the action is valid and then execute it
  24. // Everything else is taken case of by the object :)
  25. $action = strtolower($action);
  26. if (method_exists($Daemon, $action)) {
  27. $Daemon->{$action}();
  28. }
  29. else {
  30. die("ERROR: Unable to $action the daemon. This action is not recognized; instead try one of 'start', 'stop', 'restart', 'status' or 'log'.\n\n");
  31. }