]> git.mxchange.org Git - friendica.git/blob - include/poller.php
proc_run was replaced
[friendica.git] / include / poller.php
1 <?php
2 use Friendica\App;
3 use Friendica\Core\Worker;
4 use Friendica\Core\Config;
5
6 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
7         $directory = dirname($_SERVER["argv"][0]);
8
9         if (substr($directory, 0, 1) != "/") {
10                 $directory = $_SERVER["PWD"]."/".$directory;
11         }
12         $directory = realpath($directory."/..");
13
14         chdir($directory);
15 }
16
17 require_once("boot.php");
18
19 function poller_run($argv, $argc) {
20         global $a;
21
22         if (empty($a)) {
23                 $a = new App(dirname(__DIR__));
24         }
25
26         require_once ".htconfig.php";
27         require_once "include/dba.php";
28         dba::connect($db_host, $db_user, $db_pass, $db_data);
29         unset($db_host, $db_user, $db_pass, $db_data);
30
31         Config::load();
32
33         // Check the database structure and possibly fixes it
34         check_db(true);
35
36         // Quit when in maintenance
37         if (Config::get('system', 'maintenance', true)) {
38                 return;
39         }
40
41         $a->set_baseurl(Config::get('system', 'url'));
42
43         load_hooks();
44
45         // At first check the maximum load. We shouldn't continue with a high load
46         if ($a->maxload_reached()) {
47                 logger('Pre check: maximum load reached, quitting.', LOGGER_DEBUG);
48                 return;
49         }
50
51         // We now start the process. This is done after the load check since this could increase the load.
52         $a->start_process();
53
54         $run_cron = (($argc <= 1) || ($argv[1] != "no_cron"));
55
56         Worker::processQueue($run_cron);
57         return;
58 }
59
60 if (array_search(__file__, get_included_files()) === 0) {
61         poller_run($_SERVER["argv"], $_SERVER["argc"]);
62
63         Worker::unclaimProcess();
64
65         get_app()->end_process();
66
67         killme();
68 }