5 * @brief Starts the background processing
9 use Friendica\Core\Addon;
10 use Friendica\Core\Config;
11 use Friendica\Core\Worker;
16 $longopts = [ 'spawn', 'cron' ];
17 $options = getopt($shortopts, $longopts);
19 // Ensure that worker.php is executed from the base path of the installation
20 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
21 $directory = dirname($_SERVER["argv"][0]);
23 if (substr($directory, 0, 1) != "/") {
24 $directory = $_SERVER["PWD"]."/".$directory;
26 $directory = realpath($directory."/..");
31 require_once "boot.php";
33 $a = new App(dirname(__DIR__));
37 // Check the database structure and possibly fixes it
40 // Quit when in maintenance
41 if (Config::get('system', 'maintenance', false, true)) {
45 $a->set_baseurl(Config::get('system', 'url'));
49 $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
52 Worker::spawnWorker();
56 $run_cron = array_key_exists('c', $options) || array_key_exists('cron', $options);
58 Worker::processQueue($run_cron);
60 Worker::unclaimProcess();