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.

60 lines
1.2KB

  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\BaseObject;
  9. use Friendica\Core\Addon;
  10. use Friendica\Core\Config;
  11. use Friendica\Core\Worker;
  12. // Ensure that worker.php is executed from the base path of the installation
  13. if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
  14. $directory = dirname($_SERVER["argv"][0]);
  15. if (substr($directory, 0, 1) != "/") {
  16. $directory = $_SERVER["PWD"]."/".$directory;
  17. }
  18. $directory = realpath($directory."/..");
  19. chdir($directory);
  20. }
  21. require_once "boot.php";
  22. $a = new App(dirname(__DIR__));
  23. Config::load();
  24. // Check the database structure and possibly fixes it
  25. check_db(true);
  26. // Quit when in maintenance
  27. if (Config::get('system', 'maintenance', false, true)) {
  28. return;
  29. }
  30. $a->set_baseurl(Config::get('system', 'url'));
  31. Addon::loadHooks();
  32. $spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn"));
  33. if ($spawn) {
  34. Worker::spawnWorker();
  35. killme();
  36. }
  37. $run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
  38. Worker::processQueue($run_cron);
  39. Worker::unclaimProcess();
  40. Worker::endProcess();
  41. killme();