}
use Dice\Dice;
-use Friendica\App\Mode;
-use Friendica\Core\Logger\Capability\LogChannel;
-use Friendica\Core\Update;
-use Friendica\Core\Worker;
-use Friendica\DI;
-use Psr\Log\LoggerInterface;
// Get options
$options = getopt('sn', ['spawn', 'no_cron']);
$dice = (new Dice())->addRules(require(dirname(__DIR__) . '/static/dependencies.config.php'));
-/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
-$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
-$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies'));
-$dice = $dice->addRule(LoggerInterface::class, ['constructParams' => [LogChannel::WORKER]]);
+$app = \Friendica\App::fromDice($dice);
-DI::init($dice);
-\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));
-
-DI::mode()->setExecutor(Mode::WORKER);
-
-// Check the database structure and possibly fixes it
-Update::check(DI::basePath(), true);
-
-// Quit when in maintenance
-if (!DI::mode()->has(Mode::MAINTENANCEDISABLED)) {
- return;
-}
-
-$spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
-
-if ($spawn) {
- Worker::spawnWorker();
- exit();
-}
-
-$run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
-
-$process = DI::process()->create(getmypid(), basename(__FILE__));
-
-Worker::processQueue($run_cron, $process);
-
-Worker::unclaimProcess($process);
-
-DI::process()->delete($process);
+$app->processWorker($options ?: []);
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
-
-
/**
* Our main application structure for the life of this page.
*
}
}
+ public function processWorker(array $options): void
+ {
+ /** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
+ $addonLoader = $this->container->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
+ $this->container = $this->container->addRules($addonLoader->getActiveAddonConfig('dependencies'));
+
+ $this->container = $this->container->addRule(LoggerInterface::class, ['constructParams' => [LogChannel::WORKER]]);
+
+ DI::init($this->container);
+ \Friendica\Core\Logger\Handler\ErrorHandler::register($this->container->create(\Psr\Log\LoggerInterface::class));
+
+ DI::mode()->setExecutor(Mode::WORKER);
+
+ // Check the database structure and possibly fixes it
+ Update::check(DI::basePath(), true);
+
+ // Quit when in maintenance
+ if (!DI::mode()->has(Mode::MAINTENANCEDISABLED)) {
+ return;
+ }
+
+ $spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);
+
+ if ($spawn) {
+ Worker::spawnWorker();
+ exit();
+ }
+
+ $run_cron = !array_key_exists('n', $options) && !array_key_exists('no_cron', $options);
+
+ $process = DI::process()->create(getmypid(), basename(__FILE__));
+
+ Worker::processQueue($run_cron, $process);
+
+ Worker::unclaimProcess($process);
+
+ DI::process()->delete($process);
+ }
+
private function setupContainerForAddons(): void
{
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */