5 * @brief Starts the background processing
8 use Friendica\Core\Config;
9 use Friendica\Core\Worker;
13 $longopts = ['spawn', 'no_cron'];
14 $options = getopt($shortopts, $longopts);
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]);
20 if (substr($directory, 0, 1) != '/') {
21 $directory = $_SERVER["PWD"] . '/' . $directory;
23 $directory = realpath($directory . '/..');
28 require_once "boot.php";
30 $a = new App(dirname(__DIR__));
32 // Check the database structure and possibly fixes it
35 // Quit when in maintenance
36 if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
40 $a->setBaseURL(Config::get('system', 'url'));
42 $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
45 Worker::spawnWorker();
49 $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
51 Worker::processQueue($run_cron);
53 Worker::unclaimProcess();