5 * @brief Starts the background processing
10 use Friendica\BaseObject;
11 use Friendica\Core\Config;
12 use Friendica\Core\Update;
13 use Friendica\Core\Worker;
17 $longopts = ['spawn', 'no_cron'];
18 $options = getopt($shortopts, $longopts);
20 // Ensure that worker.php is executed from the base path of the installation
21 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
22 $directory = dirname($_SERVER["argv"][0]);
24 if (substr($directory, 0, 1) != '/') {
25 $directory = $_SERVER["PWD"] . '/' . $directory;
27 $directory = realpath($directory . '/..');
32 require dirname(__DIR__) . '/vendor/autoload.php';
34 $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
36 BaseObject::setDependencyInjection($dice);
37 $a = BaseObject::getApp();
39 // Check the database structure and possibly fixes it
40 Update::check($a->getBasePath(), true, $a->getMode());
42 // Quit when in maintenance
43 if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
47 $a->setBaseURL(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('n', $options) && !array_key_exists('no_cron', $options);
58 Worker::processQueue($run_cron);
60 Worker::unclaimProcess();