當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Daemon::appResolver方法代碼示例

本文整理匯總了PHP中PHPDaemon\Core\Daemon::appResolver方法的典型用法代碼示例。如果您正苦於以下問題:PHP Daemon::appResolver方法的具體用法?PHP Daemon::appResolver怎麽用?PHP Daemon::appResolver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PHPDaemon\Core\Daemon的用法示例。


在下文中一共展示了Daemon::appResolver方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init


//.........這裏部分代碼省略.........
         Daemon::log('[EMERG] 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('[EMERG] Couldn\'t create pid-file \'' . Daemon::$config->pidfile->value . '\'.');
             $error = true;
         }
         Bootstrap::$pid = 0;
     } elseif (!is_file(Daemon::$config->pidfile->value)) {
         Daemon::log('Pid-file \'' . Daemon::$config->pidfile->value . '\' must be a regular file.');
         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.');
         Bootstrap::$pid = FALSE;
         $error = true;
     } else {
         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;
         }
     }
     $pathList = preg_split('~\\s*;\\s*~', Daemon::$config->path->value);
     $found = false;
     foreach ($pathList as $path) {
         if (@is_file($path)) {
             Daemon::$appResolverPath = $path;
             $found = true;
             break;
         }
     }
     if (!$found) {
         Daemon::log('Your application resolver \'' . Daemon::$config->path->value . '\' is not available (config directive \'path\').');
         $error = true;
     }
     Daemon::$appResolver = (require Daemon::$appResolverPath);
     if (isset(Daemon::$config->group->value) && is_callable('posix_getgid')) {
         if (($sg = posix_getgrnam(Daemon::$config->group->value)) === FALSE) {
             Daemon::log('Unexisting group \'' . Daemon::$config->group->value . '\'. 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::$config->user->value) && is_callable('posix_getuid')) {
         if (($su = posix_getpwnam(Daemon::$config->user->value)) === FALSE) {
             Daemon::log('Unexisting user \'' . Daemon::$config->user->value . '\', user not found. You have to replace config-variable \'user\' with existing username.');
             $error = true;
         } elseif ($su['uid'] != posix_getuid() && posix_getuid() != 0) {
             Daemon::log('You must have the root privileges to change user.');
             $error = true;
         }
     }
     if (isset(Daemon::$config->minspareworkers->value) && Daemon::$config->minspareworkers->value > 0 && isset(Daemon::$config->maxspareworkers->value) && Daemon::$config->maxspareworkers->value > 0) {
         if (Daemon::$config->minspareworkers->value > Daemon::$config->maxspareworkers->value) {
             Daemon::log('\'minspareworkers\' cannot be greater than \'maxspareworkers\'.');
             $error = true;
         }
開發者ID:shamahan,項目名稱:phpdaemon,代碼行數:67,代碼來源:Bootstrap.php


注:本文中的PHPDaemon\Core\Daemon::appResolver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。