5 * @brief Starts the background processing
8 use Friendica\Core\Config;
9 use Friendica\Core\Worker;
10 use Friendica\Core\L10n;
14 $longopts = ['spawn', 'no_cron'];
15 $options = getopt($shortopts, $longopts);
17 // Ensure that worker.php is executed from the base path of the installation
18 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
19 $directory = dirname($_SERVER["argv"][0]);
21 if (substr($directory, 0, 1) != '/') {
22 $directory = $_SERVER["PWD"] . '/' . $directory;
24 $directory = realpath($directory . '/..');
29 require_once "boot.php";
31 $a = new App(dirname(__DIR__));
33 $lang = L10n::getBrowserLanguage();
34 L10n::loadTranslationTable($lang);
36 // Check the database structure and possibly fixes it
39 // Quit when in maintenance
40 if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
44 $a->setBaseURL(Config::get('system', 'url'));
46 $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
49 Worker::spawnWorker();
53 $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
55 Worker::processQueue($run_cron);
57 Worker::unclaimProcess();