Пример #1
0
 public function init()
 {
     Daemon::addDefaultSettings(array('mod' . $this->modname . 'listen' => 'tcp://0.0.0.0', 'mod' . $this->modname . 'listen-port' => 80, 'mod' . $this->modname . 'log-events' => 0, 'mod' . $this->modname . 'log-queue' => 0, 'mod' . $this->modname . 'send-file' => 0, 'mod' . $this->modname . 'send-file-dir' => '/dev/shm', 'mod' . $this->modname . 'send-file-prefix' => 'http-', 'mod' . $this->modname . 'send-file-onlybycommand' => 0, 'mod' . $this->modname . 'keepalive' => '0s', 'mod' . $this->modname . 'enable' => 0));
     Daemon::$parsedSettings['mod' . $this->modname . 'keepalive'] = Daemon::parseTime(Daemon::$settings['mod' . $this->modname . 'keepalive']);
     if (Daemon::$settings['mod' . $this->modname . 'enable']) {
         Daemon::log(__CLASS__ . ' up.');
         $this->bindSockets(Daemon::$settings['mod' . $this->modname . 'listen'], Daemon::$settings['mod' . $this->modname . 'listenport']);
     }
 }
Пример #2
0
 public function init()
 {
     Daemon::addDefaultSettings(array('mod' . $this->modname . 'listen' => 'tcp://127.0.0.1,unix:/tmp/phpdaemon.fcgi.sock', 'mod' . $this->modname . 'listen-port' => 9000, 'mod' . $this->modname . 'allowed-clients' => '127.0.0.1', 'mod' . $this->modname . 'log-records' => 0, 'mod' . $this->modname . 'log-records-miss' => 0, 'mod' . $this->modname . 'log-events' => 0, 'mod' . $this->modname . 'log-queue' => 0, 'mod' . $this->modname . 'send-file' => 0, 'mod' . $this->modname . 'send-file-dir' => '/dev/shm', 'mod' . $this->modname . 'send-file-prefix' => 'fcgi-', 'mod' . $this->modname . 'send-file-onlybycommand' => 0, 'mod' . $this->modname . 'keepalive' => '0s', 'mod' . $this->modname . 'enable' => 0));
     Daemon::$parsedSettings['mod' . $this->modname . 'keepalive'] = Daemon::parseTime(Daemon::$settings['mod' . $this->modname . 'keepalive']);
     if (Daemon::$settings['mod' . $this->modname . 'enable']) {
         Daemon::log(__CLASS__ . ' up.');
         $this->allowedClients = explode(',', Daemon::$settings['mod' . $this->modname . 'allowedclients']);
         $this->bindSockets(Daemon::$settings['mod' . $this->modname . 'listen'], Daemon::$settings['mod' . $this->modname . 'listenport']);
     }
 }
Пример #3
0
 public static function loadSettings($settings)
 {
     $error = FALSE;
     static $ktr = array('-' => '');
     foreach ($settings as $k => $v) {
         $k = strtolower(strtr($k, $ktr));
         if ($k === 'config') {
             $k = 'configfile';
         }
         if ($k === 'user' || $k === 'group') {
             if ($v === '') {
                 $v = NULL;
             }
         }
         if (array_key_exists($k, Daemon::$settings)) {
             if ($k === 'maxmemoryusage') {
                 Daemon::$parsedSettings[$k] = Daemon::parseSize($v);
             } elseif ($k === 'maxrequests') {
                 Daemon::$parsedSettings[$k] = Daemon::parseNum($v);
             } elseif ($k === 'autogc') {
                 Daemon::$parsedSettings[$k] = Daemon::parseNum($v);
             } elseif ($k === 'maxidle') {
                 Daemon::$parsedSettings[$k] = Daemon::parseTime($v);
             } elseif ($k === 'autoreload') {
                 Daemon::$parsedSettings[$k] = Daemon::parseTime($v);
             } elseif ($k === 'maxconcurrentrequestsperworker') {
                 Daemon::$parsedSettings[$k] = Daemon::parseNum($v);
             } elseif ($k === 'keepalive') {
                 Daemon::$parsedSettings[$k] = Daemon::parseTime($v);
             } elseif ($k === 'mpmdelay') {
                 Daemon::$parsedSettings[$k] = Daemon::parseTime($v);
             } elseif ($k === 'chunksize') {
                 Daemon::$parsedSettings[$k] = Daemon::parseSize($v);
             }
             if (is_int(Daemon::$settings[$k])) {
                 Daemon::$settings[$k] = (int) $v;
             } else {
                 Daemon::$settings[$k] = $v;
             }
         } elseif (strpos($k, 'mod') === 0) {
             Daemon::$settings[$k] = $v;
         } else {
             Daemon::log('Unrecognized parameter \'' . $k . '\'');
             $error = TRUE;
         }
     }
     if (isset($settings['path'])) {
         if (isset(Daemon::$settings['chroot'])) {
             Daemon::$pathReal = realpath(Daemon::$settings['chroot'] . (substr(Daemon::$settings['chroot'], -1) != '/' ? '/' : '') . Daemon::$settings['path']);
         } else {
             Daemon::$pathReal = realpath(Daemon::$settings['path']);
         }
     }
     return !$error;
 }