5 * Starts the background processing
10 use Friendica\Core\Update;
11 use Friendica\Core\Worker;
13 use Psr\Log\LoggerInterface;
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');
35 $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]);
40 // Check the database structure and possibly fixes it
41 Update::check($a->getBasePath(), true, DI::mode());
43 // Quit when in maintenance
44 if (!DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
48 DI::baseUrl()->saveByURL(DI::config()->get('system', 'url'));
50 $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
53 Worker::spawnWorker();
57 $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
59 Worker::processQueue($run_cron);
61 Worker::unclaimProcess();