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


PHP Daemon::initSettings方法代码示例

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


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

示例1: init

 public static function init()
 {
     Daemon::initSettings();
     Daemon::$runName = basename($_SERVER['argv'][0]);
     $error = FALSE;
     $argv = $_SERVER['argv'];
     $runmode = isset($argv[1]) ? str_replace('-', '', $argv[1]) : '';
     $args = Daemon_Bootstrap::getArgs($argv);
     if (isset($args[$k = 'configfile'])) {
         Daemon::$settings[$k] = $args[$k];
     }
     if (isset(Daemon::$settings['configfile']) && !Daemon::loadConfig(Daemon::$settings['configfile'])) {
         $error = TRUE;
     }
     if (!Daemon::loadSettings($args)) {
         $error = TRUE;
     }
     if (version_compare(PHP_VERSION, '5.3.0', '>=') === 1) {
         Daemon::log('PHP >= 5.3.0 required.');
         $error = TRUE;
     }
     if (isset(Daemon::$settings['locale'])) {
         setlocale(LC_ALL, explode(',', Daemon::$settings['locale']));
     }
     if (!is_callable('posix_kill')) {
         Daemon::log('Posix not found. You should compile PHP without \'--disable-posix\'.');
         $error = TRUE;
     }
     if (!is_callable('pcntl_signal')) {
         Daemon::log('PCNTL not found. You should compile PHP with \'--enable-pcntl\'.');
         $error = TRUE;
     }
     if (!is_callable('event_base_new')) {
         Daemon::log('libevent extension not found. You have to install libevent from pecl (http://pecl.php.net/package/libevent). `svn checkout http://svn.php.net/repository/pecl/libevent pecl-libevent`.');
         $error = TRUE;
     }
     if (!is_callable('socket_create')) {
         Daemon::log('Sockets extension not found. You should compile PHP with \'--enable-sockets\'.');
         $error = TRUE;
     }
     if (!is_callable('shmop_open')) {
         Daemon::log('Shmop extension not found. You should compile PHP with \'--enable-shmop\'.');
         $error = TRUE;
     }
     if (!isset(Daemon::$settings['user'])) {
         Daemon::log('You must set \'user\' parameter.');
         $error = TRUE;
     }
     if (!isset(Daemon::$settings['path'])) {
         Daemon::log('You must set \'path\' parameter (path to your application resolver).');
         $error = TRUE;
     }
     Daemon_Bootstrap::$pidfile = realpath(Daemon::$settings['pidfile']);
     if (!Daemon_Bootstrap::$pidfile) {
         Daemon_Bootstrap::$pidfile = Daemon::$settings['pidfile'];
     }
     if (!file_exists(Daemon_Bootstrap::$pidfile)) {
         if (!touch(Daemon_Bootstrap::$pidfile)) {
             Daemon::log('Couldn\'t create pid-file \'' . Daemon_Bootstrap::$pidfile . '\'.');
             $error = TRUE;
         }
         Daemon_Bootstrap::$pid = 0;
     } elseif (!is_file(Daemon_Bootstrap::$pidfile)) {
         Daemon::log('Pid-file \'' . Daemon_Bootstrap::$pidfile . '\' must be a regular file.');
         Daemon_Bootstrap::$pid = FALSE;
         $error = TRUE;
     } elseif (!is_writable(Daemon_Bootstrap::$pidfile)) {
         Daemon::log('Pid-file \'' . Daemon_Bootstrap::$pidfile . '\' must be writable.');
         $error = TRUE;
     } elseif (!is_readable(Daemon_Bootstrap::$pidfile)) {
         Daemon::log('Pid-file \'' . Daemon_Bootstrap::$pidfile . '\' must be readable.');
         Daemon_Bootstrap::$pid = FALSE;
         $error = TRUE;
     } else {
         Daemon_Bootstrap::$pid = (int) file_get_contents(Daemon_Bootstrap::$pidfile);
     }
     if (Daemon::$settings['chroot'] !== '/') {
         if (posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change root.');
             $error = TRUE;
         }
     }
     if (!@is_file(Daemon::$pathReal)) {
         Daemon::log('Your application resolver \'' . Daemon::$settings['path'] . '\' is not available.');
         $error = TRUE;
     }
     if (isset(Daemon::$settings['group']) && is_callable('posix_getgid')) {
         if (($sg = posix_getgrnam(Daemon::$settings['group'])) === FALSE) {
             Daemon::log('Unexisting group \'' . Daemon::$settings['group'] . '\'. You have to replace config-variable \'group\' with existing group-name.');
             $error = TRUE;
         } elseif ($sg['gid'] != posix_getgid() && posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change group.');
             $error = TRUE;
         }
     }
     if (isset(Daemon::$settings['user']) && is_callable('posix_getuid')) {
         if (($su = posix_getpwnam(Daemon::$settings['user'])) === FALSE) {
             Daemon::log('Unexisting user \'' . Daemon::$settings['user'] . '\', user not found. You have to replace config-variable \'user\' with existing username.');
             $error = TRUE;
         } elseif ($su['uid'] != posix_getuid() && posix_getuid() != 0) {
//.........这里部分代码省略.........
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:101,代码来源:Daemon_Bootstrap.class.php

示例2: init

 /**
  * Actions on early startup.
  * @return void
  */
 public static function init()
 {
     Daemon::initSettings();
     Daemon::$runName = basename($_SERVER['argv'][0]);
     $error = FALSE;
     $argv = $_SERVER['argv'];
     $runmode = isset($argv[1]) ? str_replace('-', '', $argv[1]) : '';
     $args = Daemon_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;
     }
     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 (version_compare(PHP_VERSION, '5.3.0', '>=') === 1) {
         Daemon::log('PHP >= 5.3.0 required.');
         $error = TRUE;
     }
     if (!Daemon::$useSockets) {
         Daemon::log('Cannot use socket extension, using stream_* instead. Non-critical error, but the performance compromised.');
     }
     if (isset(Daemon::$config->locale->value) && Daemon::$config->locale->value !== '') {
         setlocale(LC_ALL, explode(',', Daemon::$config->locale->value));
     }
     if (Daemon::$config->autoreimport->value && !is_callable('runkit_import')) {
         Daemon::log('runkit extension not found. You should install it or disable --auto-reimport.');
         $error = TRUE;
     }
     if (!is_callable('posix_kill')) {
         Daemon::log('Posix not found. You should compile PHP without \'--disable-posix\'.');
         $error = TRUE;
     }
     if (!is_callable('pcntl_signal')) {
         Daemon::log('PCNTL not found. You should compile PHP with \'--enable-pcntl\'.');
         $error = TRUE;
     }
     if (!is_callable('event_base_new')) {
         Daemon::log('libevent extension not found. You have to install libevent from pecl (http://pecl.php.net/package/libevent). `svn checkout http://svn.php.net/repository/pecl/libevent pecl-libevent`.');
         $error = TRUE;
     }
     if (!is_callable('socket_create')) {
         Daemon::log('Sockets extension not found. You should compile PHP with \'--enable-sockets\'.');
         $error = TRUE;
     }
     if (!is_callable('shmop_open')) {
         Daemon::log('Shmop extension not found. You should compile PHP with \'--enable-shmop\'.');
         $error = TRUE;
     }
     if (!isset(Daemon::$config->user)) {
         Daemon::log('You must set \'user\' parameter.');
         $error = TRUE;
     }
     if (!isset(Daemon::$config->path)) {
         Daemon::log('You must set \'path\' parameter (path to your application resolver).');
         $error = TRUE;
     }
     if (!file_exists(Daemon::$config->pidfile->value)) {
         if (!touch(Daemon::$config->pidfile->value)) {
             Daemon::log('Couldn\'t create pid-file \'' . Daemon::$config->pidfile->value . '\'.');
             $error = TRUE;
         }
         Daemon_Bootstrap::$pid = 0;
     } elseif (!is_file(Daemon::$config->pidfile->value)) {
         Daemon::log('Pid-file \'' . Daemon::$config->pidfile->value . '\' must be a regular file.');
         Daemon_Bootstrap::$pid = FALSE;
         $error = TRUE;
     } elseif (!is_writable(Daemon::$config->pidfile->value)) {
         Daemon::log('Pid-file \'' . Daemon::$config->pidfile->value . '\' must be writable.');
         $error = TRUE;
     } elseif (!is_readable(Daemon::$config->pidfile->value)) {
         Daemon::log('Pid-file \'' . Daemon::$config->pidfile->value . '\' must be readable.');
         Daemon_Bootstrap::$pid = FALSE;
         $error = TRUE;
     } else {
         Daemon_Bootstrap::$pid = (int) file_get_contents(Daemon::$config->pidfile->value);
     }
     if (Daemon::$config->chroot->value !== '/') {
         if (posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change root.');
             $error = TRUE;
         }
     }
     if (!@is_file(Daemon::$config->path->value)) {
//.........这里部分代码省略.........
开发者ID:J3FF3,项目名称:phpdaemon,代码行数:101,代码来源:Daemon_Bootstrap.php

示例3: compatRunEmul

 /**
  * It allows to run your simple web-apps in spawn-fcgi/php-fpm environment.
  * @return boolean - Success.
  */
 public static function compatRunEmul()
 {
     Daemon::$dir = realpath(__DIR__ . '/..');
     Daemon::$compatMode = TRUE;
     Daemon::initSettings();
     $argv = isset($_SERVER['CMD_ARGV']) ? $_SERVER['CMD_ARGV'] : '';
     $args = Daemon_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');
     }
     $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->params_done = TRUE;
     $req->attrs->stdin_done = TRUE;
     $req = $appResolver->getRequest($req);
     while (TRUE) {
         $ret = $req->call();
         if ($ret === 1) {
             return;
         }
     }
 }
开发者ID:J3FF3,项目名称:phpdaemon,代码行数:48,代码来源:Daemon.php


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