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