5 * @brief Starts the background processing
9 use Friendica\Core\Config;
10 use Friendica\Core\Update;
11 use Friendica\Core\Worker;
15 $longopts = ['spawn', 'no_cron'];
16 $options = getopt($shortopts, $longopts);
18 // Ensure that worker.php is executed from the base path of the installation
19 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
20 $directory = dirname($_SERVER["argv"][0]);
22 if (substr($directory, 0, 1) != '/') {
23 $directory = $_SERVER["PWD"] . '/' . $directory;
25 $directory = realpath($directory . '/..');
30 require dirname(__DIR__) . '/vendor/autoload.php';
32 $dice = new \Dice\Dice();
33 $dice = $dice->addRules(include __DIR__ . '/../static/dependencies.config.php');
35 \Friendica\BaseObject::setDependencyInjection($dice);
36 $a = \Friendica\BaseObject::getApp();
38 // Check the database structure and possibly fixes it
39 Update::check($a->getBasePath(), true, $a->getMode());
41 // Quit when in maintenance
42 if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
46 $a->setBaseURL(Config::get('system', 'url'));
48 $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
51 Worker::spawnWorker();
55 $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
57 Worker::processQueue($run_cron);
59 Worker::unclaimProcess();