コード例 #1
0
ファイル: WebServer.php プロジェクト: kissthink/php_qqMail
 static function create($ini_file = null)
 {
     $opt = getopt('m:h:p:d:');
     //mode, server or fastcgi
     if (empty($opt['m'])) {
         $opt['m'] = 'server';
     }
     //daemonize
     if (empty($opt['d'])) {
         $opt['d'] = false;
     }
     if ($opt['m'] == 'fastcgi') {
         $protocol = new Swoole\Protocol\AppFPM();
     } else {
         $protocol = new Swoole\Protocol\AppServer();
     }
     if ($ini_file) {
         $protocol->loadSetting($ini_file);
         //加载配置文件
     }
     //port
     if (!empty($opt['p'])) {
         $protocol->default_port = $opt['p'];
     } elseif (!empty($protocol->config['server']['port'])) {
         $protocol->default_port = $protocol->config['server']['port'];
     } else {
         $protocol->default_port = self::DEFAULT_PORT;
     }
     //host
     if (!empty($opt['h'])) {
         $protocol->default_host = $opt['h'];
     } elseif (!empty($protocol->config['server']['host'])) {
         $protocol->default_host = $protocol->config['server']['host'];
     } else {
         $protocol->default_host = self::DEFAULT_HOST;
     }
     $server = Swoole\Network\Server::autoCreate($protocol->default_host, $protocol->default_port);
     $server->setProtocol($protocol);
     if (!empty($protocol->config['server']['worker_num'])) {
         $server->runtimeSetting['worker_num'] = $protocol->config['server']['worker_num'];
     }
     return $protocol;
 }
コード例 #2
0
 static function create($ini_file = null)
 {
     $opt = getopt('m:h:p:d:');
     //mode, server or fastcgi
     if (empty($opt['m'])) {
         $opt['m'] = 'server';
     }
     //host
     if (empty($opt['h'])) {
         $opt['h'] = '0.0.0.0';
     }
     //port
     if (empty($opt['p'])) {
         $opt['p'] = 8888;
     }
     //daemonize
     if (empty($opt['d'])) {
         $opt['d'] = false;
     }
     if ($opt['m'] == 'fastcgi') {
         $protocol = new Swoole\Protocol\AppFPM();
     } else {
         $protocol = new Swoole\Protocol\AppServer();
     }
     if ($ini_file) {
         $protocol->loadSetting($ini_file);
         //加载配置文件
     }
     $protocol->default_port = $opt['p'];
     $protocol->default_host = $opt['h'];
     $server = Swoole\Network\Server::autoCreate($protocol->default_host, $protocol->default_port);
     $server->setProtocol($protocol);
     return $protocol;
 }