/** * 初始化 */ private function __construct($ip, $port) { register_shutdown_function(array($this, 'handleFatal')); $http = new \swoole_http_server($ip, $port); $http->set(\Config\Server::getWebServerConfig()); $http->on('WorkerStart', array($this, 'onWorkerStart')); $http->on('request', array($this, 'onRequest')); $http->on('start', array($this, 'onStart')); $http->start(); }
public function run($ip = "0.0.0.0", $port = 6666) { $webServer = new \swoole_http_server($ip, $port); $webServer->set(\Config\Server::getWebServerConfig()); $webServer->on('WorkerStart', array($this, 'onWorkerStart')); $webServer->on('request', array($this, 'onRequest')); $webServer->on('start', array($this, 'onStart')); $webServer->on('ManagerStart', function ($serv) { global $argv; swoole_set_process_name("php {$argv[0]}: manager"); }); $webServer->start(); }