Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

11 years ago
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * @file bin/worker.php
  5. * @brief Starts the background processing
  6. */
  7. use Friendica\App;
  8. use Friendica\Core\Config;
  9. use Friendica\Core\Worker;
  10. // Get options
  11. $shortopts = 'sn';
  12. $longopts = ['spawn', 'no_cron'];
  13. $options = getopt($shortopts, $longopts);
  14. // Ensure that worker.php is executed from the base path of the installation
  15. if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
  16. $directory = dirname($_SERVER["argv"][0]);
  17. if (substr($directory, 0, 1) != '/') {
  18. $directory = $_SERVER["PWD"] . '/' . $directory;
  19. }
  20. $directory = realpath($directory . '/..');
  21. chdir($directory);
  22. }
  23. require_once "boot.php";
  24. $a = new App(dirname(__DIR__));
  25. // Check the database structure and possibly fixes it
  26. check_db(true);
  27. // Quit when in maintenance
  28. if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
  29. return;
  30. }
  31. $a->setBaseURL(Config::get('system', 'url'));
  32. $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
  33. if ($spawn) {
  34. Worker::spawnWorker();
  35. killme();
  36. }
  37. $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
  38. Worker::processQueue($run_cron);
  39. Worker::unclaimProcess();
  40. Worker::endProcess();