当前位置: 首页>>代码示例>>PHP>>正文


PHP Daemon::loadConfig方法代码示例

本文整理汇总了PHP中PHPDaemon\Core\Daemon::loadConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::loadConfig方法的具体用法?PHP Daemon::loadConfig怎么用?PHP Daemon::loadConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPDaemon\Core\Daemon的用法示例。


在下文中一共展示了Daemon::loadConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compatRunEmul

 /**
  * It allows to run your simple web-apps in spawn-fcgi/php-fpm environment.
  * @return boolean|null - Success.
  */
 public static function compatRunEmul()
 {
     Daemon::$compatMode = TRUE;
     Daemon::initSettings();
     $argv = isset($_SERVER['CMD_ARGV']) ? $_SERVER['CMD_ARGV'] : '';
     $args = \PHPDaemon\Core\Bootstrap::getArgs($argv);
     if (isset($args[$k = 'configfile'])) {
         Daemon::$config[$k] = $args[$k];
     }
     if (!Daemon::$config->loadCmdLineArgs($args)) {
         $error = true;
     }
     if (isset(Daemon::$config->configfile->value) && !Daemon::loadConfig(Daemon::$config->configfile->value)) {
         $error = true;
     }
     if (!isset(Daemon::$config->path->value)) {
         exit('\'path\' is not defined');
     }
     if ($error) {
         exit;
     }
     $appResolver = (require Daemon::$config->path->value);
     $appResolver->init();
     $req = new \stdClass();
     $req->attrs = new \stdClass();
     $req->attrs->request = $_REQUEST;
     $req->attrs->get = $_GET;
     $req->attrs->post = $_REQUEST;
     $req->attrs->cookie = $_REQUEST;
     $req->attrs->server = $_SERVER;
     $req->attrs->files = $_FILES;
     $req->attrs->session = isset($_SESSION) ? $_SESSION : null;
     $req->attrs->connId = 1;
     $req->attrs->trole = 'RESPONDER';
     $req->attrs->flags = 0;
     $req->attrs->id = 1;
     $req->attrs->paramsDone = true;
     $req->attrs->inputDone = true;
     $req = $appResolver->getRequest($req);
     while (true) {
         $ret = $req->call();
         if ($ret === 1) {
             return;
         }
     }
 }
开发者ID:aleksraiden,项目名称:phpdaemon-sockjs-example,代码行数:50,代码来源:Daemon.php

示例2: init

 /**
  * Actions on early startup.
  * @param string Optional. Config file path.
  * @return void
  */
 public static function init($configFile = null)
 {
     if (!version_compare(PHP_VERSION, '5.4.0', '>=')) {
         Daemon::log('PHP >= 5.4.0 required.');
         return;
     }
     //run without composer
     if (!function_exists('setTimeout')) {
         require 'PHPDaemon/Utils/func.php';
     }
     Daemon::initSettings();
     FileSystem::init();
     Daemon::$runName = basename($_SERVER['argv'][0]);
     $error = FALSE;
     $argv = $_SERVER['argv'];
     $runmode = isset($argv[1]) ? str_replace('-', '', $argv[1]) : '';
     $args = Bootstrap::getArgs($argv);
     if (!isset(self::$params[$runmode]) && !in_array($runmode, self::$commands)) {
         if ('' !== $runmode) {
             echo 'Unrecognized command: ' . $runmode . "\n";
         }
         self::printUsage();
         exit;
     } elseif ('help' === $runmode) {
         self::printHelp();
         exit;
     }
     $n = null;
     if ('log' === $runmode) {
         if (isset($args['n'])) {
             $n = $args['n'];
             unset($args['n']);
         } else {
             $n = 20;
         }
     }
     if (isset($configFile)) {
         Daemon::$config->configfile->setHumanValue($configFile);
     }
     if (isset($args['configfile'])) {
         Daemon::$config->configfile->setHumanValue($args['configfile']);
     }
     if (!Daemon::$config->loadCmdLineArgs($args)) {
         $error = true;
     }
     if (!Daemon::loadConfig(Daemon::$config->configfile->value)) {
         $error = true;
     }
     if ('log' === $runmode) {
         passthru('tail -n ' . $n . ' -f ' . escapeshellarg(Daemon::$config->logstorage->value));
         exit;
     }
     if (extension_loaded('apc') && ini_get('apc.enabled')) {
         Daemon::log('Detected pecl-apc extension enabled. Usage of bytecode caching (APC/eAccelerator/xcache/...)  makes no sense at all in case of using phpDaemon \'cause phpDaemon includes files just in time itself.');
     }
     if (isset(Daemon::$config->locale->value) && Daemon::$config->locale->value !== '') {
         setlocale(LC_ALL, array_map('trim', explode(',', Daemon::$config->locale->value)));
     }
     if (Daemon::$config->autoreimport->value && !is_callable('runkit_import')) {
         Daemon::log('[WARN] runkit extension not found. You should install it or disable --auto-reimport. Non-critical error.');
     }
     if (!is_callable('posix_kill')) {
         Daemon::log('[EMERG] Posix not found. You should compile PHP without \'--disable-posix\'.');
         $error = true;
     }
     if (!is_callable('pcntl_signal')) {
         Daemon::log('[EMERG] PCNTL not found. You should compile PHP with \'--enable-pcntl\'.');
         $error = true;
     }
     if (extension_loaded('libevent')) {
         Daemon::log('[EMERG] libevent extension found. You have to remove libevent.so extension.');
         $error = true;
     }
     $eventVer = '1.6.1';
     $eventVerType = 'stable';
     if (!Daemon::loadModuleIfAbsent('event', $eventVer . '-' . $eventVerType)) {
         Daemon::log('[EMERG] event extension >= ' . $eventVer . ' not found (or OUTDATED). You have to install it. `pecl install http://pecl.php.net/get/event`');
         $error = true;
     }
     if (!is_callable('socket_create')) {
         Daemon::log('[EMERG] Sockets extension not found. You should compile PHP with \'--enable-sockets\'.');
         $error = true;
     }
     if (!is_callable('shmop_open')) {
         Daemon::log('[EMERG] Shmop extension not found. You should compile PHP with \'--enable-shmop\'.');
         $error = true;
     }
     if (!isset(Daemon::$config->user)) {
         Daemon::log('[EMERG] You must set \'user\' parameter.');
         $error = true;
     }
     if (!isset(Daemon::$config->path)) {
         Daemon::log('[EMERG] You must set \'path\' parameter (path to your application resolver).');
         $error = true;
     }
//.........这里部分代码省略.........
开发者ID:shamahan,项目名称:phpdaemon,代码行数:101,代码来源:Bootstrap.php

示例3: sighup

 /**
  * Handler of the SIGHUP (reload config) signal in worker process.
  * @return void
  */
 protected function sighup()
 {
     if (Daemon::$config->logsignals->value) {
         $this->log('caught SIGHUP (reload config).');
     }
     if (isset(Daemon::$config->configfile->value)) {
         Daemon::loadConfig(Daemon::$config->configfile->value);
     }
     $this->update = true;
 }
开发者ID:cobolbaby,项目名称:phpdaemon,代码行数:14,代码来源:Worker.php

示例4: sighup

 /**
  * Handler for the SIGHUP (reload config) signal in master process
  * @return void
  */
 protected function sighup()
 {
     if (Daemon::$config->logsignals->value) {
         $this->log('Caught SIGHUP (reload config).');
     }
     if (isset(Daemon::$config->configfile)) {
         Daemon::loadConfig(Daemon::$config->configfile->value);
     }
     $this->signalToChildren(SIGHUP);
 }
开发者ID:shamahan,项目名称:phpdaemon,代码行数:14,代码来源:Master.php


注:本文中的PHPDaemon\Core\Daemon::loadConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。