]> git.mxchange.org Git - friendica.git/blob - bin/worker.php
Create config keys if they not exists on set.
[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 BaseObject::setApp($a);
31
32 require_once ".htconfig.php";
33 dba::connect($db_host, $db_user, $db_pass, $db_data);
34 unset($db_host, $db_user, $db_pass, $db_data);
35
36 Config::load();
37
38 // Check the database structure and possibly fixes it
39 check_db(true);
40
41 // Quit when in maintenance
42 if (Config::get('system', 'maintenance', false, true)) {
43         return;
44 }
45
46 $a->set_baseurl(Config::get('system', 'url'));
47
48 Addon::loadHooks();
49
50 $spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn"));
51
52 if ($spawn) {
53         Worker::spawnWorker();
54         killme();
55 }
56
57 $run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
58
59 Worker::processQueue($run_cron);
60
61 Worker::unclaimProcess();
62
63 Worker::endProcess();
64
65 killme();
66