X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=bin%2Fworker.php;h=46638a9ef3ad3b3a3bbe30d40ab9221e0a51c982;hb=bf81f21001cead41585ecd549a98afe4e2797840;hp=a64b6a83305660f705bf5530141061ddcf379269;hpb=2e602afd3e1be80dc0e14db98ce0445c58d5231c;p=friendica.git diff --git a/bin/worker.php b/bin/worker.php index a64b6a8330..46638a9ef3 100755 --- a/bin/worker.php +++ b/bin/worker.php @@ -1,14 +1,38 @@ #!/usr/bin/env php . + * + * Starts the background processing */ + +if (php_sapi_name() !== 'cli') { + header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden'); + exit(); +} + +use Dice\Dice; use Friendica\App; -use Friendica\Core\Config; -use Friendica\Core\Worker; +use Friendica\App\Mode; use Friendica\Core\Update; -use Friendica\Util\LoggerFactory; +use Friendica\Core\Worker; +use Friendica\DI; +use Psr\Log\LoggerInterface; // Get options $shortopts = 'sn'; @@ -29,19 +53,23 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) { require dirname(__DIR__) . '/vendor/autoload.php'; -$logger = LoggerFactory::create('worker'); +$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); +$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]); + +DI::init($dice); +$a = DI::app(); -$a = new App(dirname(__DIR__), $logger); +DI::mode()->setExecutor(Mode::WORKER); // Check the database structure and possibly fixes it -Update::check(true); +Update::check($a->getBasePath(), true, DI::mode()); // Quit when in maintenance -if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) { +if (!DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) { return; } -$a->setBaseURL(Config::get('system', 'url')); +DI::baseUrl()->saveByURL(DI::config()->get('system', 'url')); $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options); @@ -56,4 +84,4 @@ Worker::processQueue($run_cron); Worker::unclaimProcess(); -Worker::endProcess(); +DI::process()->end();