]> git.mxchange.org Git - friendica.git/blob - bin/worker.php
Fixed E_NOTICE when no valid result has been returned. (#5457)
[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
28 $a = new App(dirname(__DIR__));
29
30 Config::load();
31
32 // Check the database structure and possibly fixes it
33 check_db(true);
34
35 // Quit when in maintenance
36 if (Config::get('system', 'maintenance', false, true)) {
37         return;
38 }
39
40 $a->set_baseurl(Config::get('system', 'url'));
41
42 Addon::loadHooks();
43
44 $spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn"));
45
46 if ($spawn) {
47         Worker::spawnWorker();
48         killme();
49 }
50
51 $run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
52
53 Worker::processQueue($run_cron);
54
55 Worker::unclaimProcess();
56
57 Worker::endProcess();
58
59 killme();