Simplify bin/worker

- Remove duplicate calls to Addon::loadHooks and Config::load
- Remove useless killme() call
This commit is contained in:
Hypolite Petovan 2018-10-21 22:25:53 -04:00
parent 279196959c
commit e2ac36e43e

View File

@ -4,9 +4,7 @@
* @file bin/worker.php * @file bin/worker.php
* @brief Starts the background processing * @brief Starts the background processing
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -20,10 +18,10 @@ $options = getopt($shortopts, $longopts);
if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) { if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_SERVER["argv"][0]); $directory = dirname($_SERVER["argv"][0]);
if (substr($directory, 0, 1) != "/") { if (substr($directory, 0, 1) != '/') {
$directory = $_SERVER["PWD"]."/".$directory; $directory = $_SERVER["PWD"] . '/' . $directory;
} }
$directory = realpath($directory."/.."); $directory = realpath($directory . '/..');
chdir($directory); chdir($directory);
} }
@ -32,8 +30,6 @@ require_once "boot.php";
$a = new App(dirname(__DIR__)); $a = new App(dirname(__DIR__));
Config::load();
$lang = L10n::getBrowserLanguage(); $lang = L10n::getBrowserLanguage();
L10n::loadTranslationTable($lang); L10n::loadTranslationTable($lang);
@ -41,14 +37,12 @@ L10n::loadTranslationTable($lang);
check_db(true); check_db(true);
// Quit when in maintenance // Quit when in maintenance
if (Config::get('system', 'maintenance', false, true)) { if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
return; return;
} }
$a->setBaseURL(Config::get('system', 'url')); $a->setBaseURL(Config::get('system', 'url'));
Addon::loadHooks();
$spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options); $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
if ($spawn) { if ($spawn) {
@ -63,5 +57,3 @@ Worker::processQueue($run_cron);
Worker::unclaimProcess(); Worker::unclaimProcess();
Worker::endProcess(); Worker::endProcess();
killme();