mode = $mode; $this->config = $config; $this->keyValue = $keyValue; $this->jetstream = $jetstream; $this->daemon = $daemon; $this->addonHelper = $addonHelper; } protected function getHelp(): string { return <<mode->isInstall()) { throw new RuntimeException("Friendica isn't properly installed yet"); } $this->config->reload(); if (empty($this->config->get('jetstream', 'pidfile'))) { throw new RuntimeException( <<< TXT Please set jetstream.pidfile in config/local.config.php. For example: 'jetstream' => [ 'pidfile' => '/path/to/jetstream.pid', ], TXT ); } $this->addonHelper->loadAddons(); Hook::loadHooks(); if (!$this->addonHelper->isAddonEnabled('bluesky')) { throw new RuntimeException("Bluesky has to be enabled.\n"); } $pidfile = $this->config->get('jetstream', 'pidfile'); $daemonMode = $this->getArgument(0); $foreground = $this->getOption(['f', 'foreground']) ?? false; if (empty($daemonMode)) { throw new RuntimeException("Please use either 'start', 'stop' or 'status'"); } $this->daemon->init($pidfile); if ($daemonMode == 'status') { if ($this->daemon->isRunning()) { $this->out(sprintf("Daemon process %s is running (%s)", $this->daemon->getPid(), $this->daemon->getPidfile())); } else { $this->out(sprintf("Daemon process %s isn't running (%s)", $this->daemon->getPid(), $this->daemon->getPidfile())); } return 0; } if ($daemonMode == 'stop') { if (!$this->daemon->isRunning()) { $this->out(sprintf("Daemon process %s isn't running (%s)", $this->daemon->getPid(), $this->daemon->getPidfile())); return 0; } if ($this->daemon->stop()) { $this->keyValue->set('worker_daemon_mode', false); $this->out(sprintf("Daemon process %s was killed (%s)", $this->daemon->getPid(), $this->daemon->getPidfile())); return 0; } return 1; } if ($this->daemon->isRunning()) { $this->out(sprintf("Daemon process %s is already running (%s)", $this->daemon->getPid(), $this->daemon->getPidfile())); return 1; } if ($daemonMode == "start") { $this->out("Starting Jetstream daemon"); $this->daemon->start(function () { $this->jetstream->listen(); }, $foreground); return 0; } $this->err('Invalid command'); $this->out($this->getHelp()); return 1; } }