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.

67 lines
1.3KB

  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * @file scripts/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. require_once "include/dba.php";
  23. $a = new App(dirname(__DIR__));
  24. BaseObject::setApp($a);
  25. require_once ".htconfig.php";
  26. dba::connect($db_host, $db_user, $db_pass, $db_data);
  27. unset($db_host, $db_user, $db_pass, $db_data);
  28. Config::load();
  29. // Check the database structure and possibly fixes it
  30. check_db(true);
  31. // Quit when in maintenance
  32. if (Config::get('system', 'maintenance', true)) {
  33. return;
  34. }
  35. $a->set_baseurl(Config::get('system', 'url'));
  36. Addon::loadHooks();
  37. $spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn"));
  38. if ($spawn) {
  39. Worker::spawnWorker();
  40. killme();
  41. }
  42. $run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
  43. Worker::processQueue($run_cron);
  44. Worker::unclaimProcess();
  45. Worker::endProcess();
  46. killme();