]> git.mxchange.org Git - friendica.git/blob - bin/worker.php
Merge pull request #6013 from JonnyTischbein/issue_comment_media_link_prompt
[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 use Friendica\App;
8 use Friendica\Core\Config;
9 use Friendica\Core\Worker;
10
11 // Get options
12 $shortopts = 'sn';
13 $longopts = ['spawn', 'no_cron'];
14 $options = getopt($shortopts, $longopts);
15
16 // Ensure that worker.php is executed from the base path of the installation
17 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
18         $directory = dirname($_SERVER["argv"][0]);
19
20         if (substr($directory, 0, 1) != '/') {
21                 $directory = $_SERVER["PWD"] . '/' . $directory;
22         }
23         $directory = realpath($directory . '/..');
24
25         chdir($directory);
26 }
27
28 require_once "boot.php";
29
30 $a = new App(dirname(__DIR__));
31
32 // Check the database structure and possibly fixes it
33 check_db(true);
34
35 // Quit when in maintenance
36 if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
37         return;
38 }
39
40 $a->setBaseURL(Config::get('system', 'url'));
41
42 $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
43
44 if ($spawn) {
45         Worker::spawnWorker();
46         killme();
47 }
48
49 $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
50
51 Worker::processQueue($run_cron);
52
53 Worker::unclaimProcess();
54
55 Worker::endProcess();