5 * @brief Starts the background processing
9 use Friendica\Core\Config;
10 use Friendica\Core\Update;
11 use Friendica\Core\Worker;
12 use Friendica\Factory;
16 $longopts = ['spawn', 'no_cron'];
17 $options = getopt($shortopts, $longopts);
19 // Ensure that worker.php is executed from the base path of the installation
20 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
21 $directory = dirname($_SERVER["argv"][0]);
23 if (substr($directory, 0, 1) != '/') {
24 $directory = $_SERVER["PWD"] . '/' . $directory;
26 $directory = realpath($directory . '/..');
31 require dirname(__DIR__) . '/vendor/autoload.php';
33 $a = Factory\DependencyFactory::setUp('worker', dirname(__DIR__));
35 // Check the database structure and possibly fixes it
36 Update::check($a->getBasePath(), true);
38 // Quit when in maintenance
39 if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
43 $a->setBaseURL(Config::get('system', 'url'));
45 $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
48 Worker::spawnWorker();
52 $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
54 Worker::processQueue($run_cron);
56 Worker::unclaimProcess();