]> git.mxchange.org Git - friendica.git/blob - bin/worker.php
Set BaseObject::setApp in App
[friendica.git] / bin / worker.php
1 #!/usr/bin/env php
2 <?php
3 /**
4  * @file bin/worker.php
5  * @brief Starts the background processing
6  */
7
8 use Friendica\App;
9 use Friendica\BaseObject;
10 use Friendica\Core\Addon;
11 use Friendica\Core\Config;
12 use Friendica\Core\Worker;
13
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
18         if (substr($directory, 0, 1) != "/") {
19                 $directory = $_SERVER["PWD"]."/".$directory;
20         }
21         $directory = realpath($directory."/..");
22
23         chdir($directory);
24 }
25
26 require_once "boot.php";
27 require_once "include/dba.php";
28
29 $a = new App(dirname(__DIR__));
30
31 require_once ".htconfig.php";
32 dba::connect($db_host, $db_user, $db_pass, $db_data);
33 unset($db_host, $db_user, $db_pass, $db_data);
34
35 Config::load();
36
37 // Check the database structure and possibly fixes it
38 check_db(true);
39
40 // Quit when in maintenance
41 if (Config::get('system', 'maintenance', false, true)) {
42         return;
43 }
44
45 $a->set_baseurl(Config::get('system', 'url'));
46
47 Addon::loadHooks();
48
49 $spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn"));
50
51 if ($spawn) {
52         Worker::spawnWorker();
53         killme();
54 }
55
56 $run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
57
58 Worker::processQueue($run_cron);
59
60 Worker::unclaimProcess();
61
62 Worker::endProcess();
63
64 killme();