Loads to configuration from the daemon options and installs signal
handlers.

@param DaemonOptionsInterface $daemonOptions
187923
private function setupDaemon(DaemonOptionsInterface $daemonOptions): void
    {
        $this->requestCount = 0;
        $this->requestLimit = (int) $daemonOptions->getOption(DaemonOptions::REQUEST_LIMIT);
        $this->memoryLimit  = (int) $daemonOptions->getOption(DaemonOptions::MEMORY_LIMIT);
        $this->autoShutdown = (bool) $daemonOptions->getOption(DaemonOptions::AUTO_SHUTDOWN);

        $timeLimit = (int) $daemonOptions->getOption(DaemonOptions::TIME_LIMIT);

        if (DaemonOptions::NO_LIMIT !== $timeLimit) {
            pcntl_alarm($timeLimit);
        }

        $this->installSignalHandlers();
    }
1275317
private function loadBlockDefaults(BlockInterface $block)
    {
        $service = $this->blockManager->get($block);

        $resolver = new OptionsResolver();
        // use new interface method whenever possible
        // NEXT_MAJOR: Remove this check and legacy setDefaultSettings method call
        if (method_exists($service, 'configureSettings')) {
            $service->configureSettings($resolver);
        } else {
            $service->setDefaultSettings($resolver);
        }

        try {
            $block->setSettings($resolver->resolve($block->getSettings()));
        } catch (InvalidOptionsException $e) {
            // @TODO : add a logging error or a flash message
        }

        $service->load($block);

        return $block;
    }
456367
public function daemon(ListenerOptions $options)
    {
        $this->listenForSignals();

        $lastRestart = $this->getTimestampOfLastQueueRestart();

        $this->getEventsManager()->fire('listener:beforeDaemonLoop', $this);

        while (true) {
            // Before reserving any jobs, we will make sure this queue is not paused and
            // if it is we will just pause this worker for a given amount of time and
            // make sure we do not need to kill this worker process off completely.
            if (!$this->daemonShouldRun($options)) {
                $this->pauseWorker($options, $lastRestart);
                continue;
            }

            // 尝试使用长轮询的方式获取消息，如果当前没有，则休眠sleep时间。
            $job = $this->getNextJob($options);

            // 如果成功取到一个消息，则进入处理，并且设置超时时间
            if ($job) {
                $this->registerTimeoutHandler($job, $options);

                $this->runJob($job, $options);

                $this->clearTimeoutAlarm($options);
            }

            // Finally, we will check to see if we have exceeded our memory limits or if
            // the queue should restart based on other indications. If so, we'll stop
            // this worker and let whatever is "monitoring" it restart the process.
            $this->stopIfNecessary($options, $lastRestart);
        }

        $this->getEventsManager()->fire('listener:afterDaemonLoop', $this);
    }
1134176
public function loadPluginConfiguration(): void
	{
		$builder = $this->getContainerBuilder();
		$global = $this->compiler->getExtension()->getConfig();
		$config = $this->getConfig();

		if ($config['tracy'] === true) {
			$builder->addDefinition($this->prefix('tracy'))
				->setFactory(TracyMiddleware::class . '::factory', [$global['debug']])
				->addTag(MiddlewaresExtension::MIDDLEWARE_TAG, ['priority' => 100]);
		}

		if ($config['autobasepath'] === true) {
			$builder->addDefinition($this->prefix('autobasepath'))
				->setFactory(AutoBasePathMiddleware::class)
				->addTag(MiddlewaresExtension::MIDDLEWARE_TAG, ['priority' => 200]);
		}

		$builder->addDefinition($this->prefix('api'))
			->setFactory(ApiMiddleware::class)
			->addTag(MiddlewaresExtension::MIDDLEWARE_TAG, ['priority' => 500]);
	}
220317
public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $processedConfiguration = $this->processConfiguration($configuration, $configs);
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load('services.xml');

        $this->passConfigurationToOptions($container, $processedConfiguration);

        $container->getDefinition(ClientBuilderInterface::class)
            ->setConfigurator([ClientBuilderConfigurator::class, 'configure']);

        foreach ($processedConfiguration['listener_priorities'] as $key => $priority) {
            $container->setParameter('sentry.listener_priorities.' . $key, $priority);
        }

        $this->tagConsoleErrorListener($container);
    }
589595
public function configure(array $params): void
    {
        $dbHelperClass = DBHelper\DriverGuesser::getDBHelper($params['driver']);

        // Set specific options
        $params['driverOptions'] = $dbHelperClass::getDriverOptions();
        $this->conn = DriverManager::getConnection($params, new DbalConfiguration());
        $this->conn->setFetchMode(\Doctrine\DBAL\FetchMode::ASSOCIATIVE);

        $this->dbHelper = new $dbHelperClass($this->conn);
    }
136194
public function addOptions( $options ) {
		foreach ( $options as $key => $option ) {
			if ( is_int( $key ) ) {
				$this->addOption( $option );
			} else {
				$this->addOption( $key, $option );
			}
		}
	}
1356018
public function setOptions(array $options = null): void
    {
        // store options by default
        $this->options = (array)$options;

        // apply options
        foreach ($this->options as $key => $value) {
            $this->setOption($key, $value);
        }
    }
163817
public function addOptions(array $options)
    {
        $this->options = array_merge($this->options, $options);

        $this->getDefinitionLoader()->setOptions($options);
    }
534008
public function setOptions(array $options = [])
    {
        if ($this->isRunning()) {
            throw new LogicException('Options cannot be set while the server is running.');
        }

        $this->options = array_diff_key($this->options, $options) + $options;

        $this->swooleServer->set($this->options);
    }
778827
public function addOptions(array $options): void
	{
		foreach ($options as $key => $option) {
			$this->addOption($key, $option);
		}
	}
1025974
protected function configure(array $options): void
    {
        $options = array_merge([
            'socket_class' => ClientSocket::class,
            'on_data_callback' => null,
            'socket_options' => [],
        ], $options);

        parent::configure($options);
    }
485460
protected static function _setupOptions(&$options)
    {
        $options = self::_merge(self::$_defaults, $options);
        foreach ($options['children'] as &$child) {
            self::_setupOptions($child);
        }
    }
596475
protected void registerOptionHandlers() {
        try {
            for (Class c : Index.list(OptionHandlerExtension.class, Jenkins.getActiveInstance().pluginManager.uberClassLoader,Class.class)) {
                Type t = Types.getBaseClass(c, OptionHandler.class);
                CmdLineParser.registerHandler(Types.erasure(Types.getTypeArgument(t,0)), c);
            }
        } catch (IOException e) {
            throw new Error(e);
        }
    }
1264412
protected function configureHandlers(array $handlers)
    {
        foreach ($handlers as $handlerId => $handlerOptions) {
            $handlerLoader = new HandlerLoader($handlerOptions, $this->formatters, $this->processors, $this->handlers);
            $this->handlers[$handlerId] = $handlerLoader->load();
        }
    }
1337007
public function load(array $configs, ContainerBuilder $container): void
    {
        $configuration = new Configuration($this->getAlias());
        $this->processConfiguration($configuration, $configs);

        foreach (Iter::makeOneDimension($configs[0], self::ALIAS) as $key => $value) {
            $container->setParameter($key, $value);
        }
    }
703469
protected function processOptions(InputInterface $input, OutputInterface $output): void
    {
        $exclude = TypeCast::castString($input->getOption('exclude'));
        $format = $input->getOption('format');
        $this->format = is_string($format) ? $format : null;
        $basePath = $input->getOption('directory');
        $this->basePath = is_string($basePath) ? $basePath : './';

        // Add slash to the path
        if (substr($this->basePath, -1) !== '/') {
            $this->basePath .= '/';
        }

        $this->verbose = $output->isVerbose();
        $this->output = $output;
        $this->skipClasses = (bool)$input->getOption('skip-classes');
        $this->skipMethods = (bool)$input->getOption('skip-methods');
        $this->skipSignatures = (bool)$input->getOption('skip-signatures');

        // Set up excludes:
        if (!empty($exclude)) {
            $this->exclude = array_map('trim', explode(',', $exclude));
        }
    }