本文整理汇总了PHP中Daemon::loadConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::loadConfig方法的具体用法?PHP Daemon::loadConfig怎么用?PHP Daemon::loadConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Daemon
的用法示例。
在下文中一共展示了Daemon::loadConfig方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sighup
public function sighup()
{
if (Daemon::$settings['logsignals']) {
Daemon::log('Worker ' . getmypid() . ' caught SIGHUP (reload config).');
}
if (isset(Daemon::$settings['configfile'])) {
Daemon::loadConfig(Daemon::$settings['configfile']);
}
$this->update = TRUE;
}
示例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)) {
//.........这里部分代码省略.........
示例3: 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) {
//.........这里部分代码省略.........
示例4: sighup
/**
* Handler for the SIGHUP (reload config) signal in master process
* @todo +on & -> protected?
* @return void
*/
public function sighup()
{
if (Daemon::$config->logsignals->value) {
Daemon::log('Master caught SIGHUP (reload config).');
}
if (isset(Daemon::$config->configfile)) {
Daemon::loadConfig(Daemon::$config->configfile->value);
}
$this->workers->signal(SIGHUP);
}
示例5: sighup
/**
* Handler of the SIGHUP (reload config) signal in worker process.
* @return void
*/
public 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;
}
示例6: sighup
public function sighup()
{
if (Daemon::$settings['logsignals']) {
Daemon::log('Master caught SIGHUP (reload config).');
}
if (isset(Daemon::$settings['configfile'])) {
Daemon::loadConfig(Daemon::$settings['configfile']);
}
$this->collections['workers']->signal(SIGHUP);
}
示例7: 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;
}
}
}