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


PHP Daemon::loadSettings方法代码示例

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


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

 public static function loadConfig($path)
 {
     if (!is_file($p = realpath($path))) {
         Daemon::log('Couldn\'t read the config file \'' . $path . '\'.');
         return FALSE;
     }
     $cfg = (include $p);
     if (!is_array($cfg)) {
         Daemon::log('Config file \'' . $p . '\' returned bad value.');
         return FALSE;
     }
     if (!Daemon::loadSettings($cfg)) {
         return FALSE;
     }
     return TRUE;
 }
开发者ID:svcorp77,项目名称:phpdaemon,代码行数:16,代码来源:Daemon.class.php


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