tripal_launch_jobs.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @file
  4. * This script will launch any waiting tripal jobs in succession.
  5. *
  6. * This script must be run at the base directory level of the drupal installation
  7. * in order to pick up all necessary dependencies
  8. */
  9. $stdout = fopen('php://stdout', 'w');
  10. // we require one command-line argument
  11. if (sizeof($argv) < 2) {
  12. print_usage($stdout);
  13. exit;
  14. }
  15. $drupal_base_url = parse_url('http://www.example.com');
  16. $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
  17. // $_SERVER['PHP_SELF'] = $drupal_base_url['path'].'/index.php';
  18. $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
  19. $_SERVER['REMOTE_ADDR'] = NULL;
  20. $_SERVER['REQUEST_METHOD'] = NULL;
  21. require_once 'includes/bootstrap.inc';
  22. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  23. // check to make sure the username is valid
  24. $username = $argv[1];
  25. $do_parallel = $argv[2];
  26. if (!db_fetch_object(db_query("SELECT * FROM {users} WHERE name = '%s'", $username))) {
  27. fwrite($stdout, "'$username' is not a valid Drupal username. exiting...\n");
  28. exit;
  29. }
  30. global $user;
  31. $user = user_load(array('name' => $username));
  32. fwrite($stdout, "Tripal Job Launcher\n");
  33. fwrite($stdout, "Running as user ' . $username . '\n");
  34. fwrite($stdout, "-------------------\n");
  35. tripal_jobs_launch($do_parallel);
  36. /**
  37. * Print out the usage instructions if they are not followed correctly
  38. *
  39. * @ingroup tripal_core
  40. */
  41. function print_usage($stdout) {
  42. fwrite($stdout, "Usage:\n");
  43. fwrite($stdout, " php ./sites/all/modules/tripal_core/tripal_launch_jobs <username> \n\n");
  44. fwrite($stdout, " where <username> is a Drupal user name\n\n");
  45. }