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;
14 use Psr\Log\LoggerInterface;
18 $longopts = ['spawn', 'no_cron'];
19 $options = getopt($shortopts, $longopts);
21 // Ensure that worker.php is executed from the base path of the installation
22 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
23 $directory = dirname($_SERVER["argv"][0]);
25 if (substr($directory, 0, 1) != '/') {
26 $directory = $_SERVER["PWD"] . '/' . $directory;
28 $directory = realpath($directory . '/..');
33 require dirname(__DIR__) . '/vendor/autoload.php';
35 $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
36 $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]);
38 BaseObject::setDependencyInjection($dice);
39 $a = BaseObject::getApp();
41 // Check the database structure and possibly fixes it
42 Update::check($a->getBasePath(), true, $a->getMode());
44 // Quit when in maintenance
45 if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
49 $a->setBaseURL(Config::get('system', 'url'));
51 $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
54 Worker::spawnWorker();
58 $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
60 Worker::processQueue($run_cron);
62 Worker::unclaimProcess();