private function initServer()

in provider/core/server/BaseServer.php [304:357]


    private function initServer() 
    {
        // Creating a swoole server resource object
        $swooleServerName = '\swoole_server';
        $this->sw = new $swooleServerName($this->host, $this->port, $this->mode, $this->sockType);
        
        //create monitor
    	$monitor = new AppMonitor($this->processName, $this->config);
        //设置appMonitor
        $monitor->setServer($this->sw);
        $this->sw->appMonitor = $monitor;

		//创建overload monitor
		$this->overloadMonitor = new OverloadMonitor($this->processName);

        //对整数进行容错处理
		$this->setting['worker_num'] = intval($this->setting['worker_num']);
        $this->setting['dispatch_mode'] = intval($this->setting['dispatch_mode']);
        $this->setting['daemonize'] = intval($this->setting['daemonize']);

        // Setting the runtime parameters
        $this->sw->set($this->setting);

        // Set Event Server callback function
        $this->sw->on('Start', array($this, 'onMasterStart'));
        $this->sw->on('ManagerStart', array($this, 'onManagerStart'));
        $this->sw->on('ManagerStop', array($this, 'onManagerStop'));
        $this->sw->on('WorkerStart', array($this, 'onWorkerStart'));
        $this->sw->on('Connect', array($this, 'onConnect'));
        $this->sw->on('Receive', array($this, 'onReceive'));
        $this->sw->on('Close', array($this, 'onClose'));
        $this->sw->on('WorkerStop', array($this, 'onWorkerStop'));
        //$this->sw->on('timer', array($this, 'onTimer'));
        if (isset($this->setting['task_worker_num'])) 
        {
            $this->sw->on('Task', array($this, 'onTask'));
            $this->sw->on('Finish', array($this, 'onFinish'));
        }
		$this->sw->on('WorkerError', array($this, 'onWorkerError'));

        // add listener
        if (is_array($this->listen))
        {
            foreach($this->listen as $v)
            {
                if (empty($v['host']) || empty($v['port']))
                {
                    continue;
                }
                $this->sw->addlistener($v['host'], $v['port'], $this->sockType);
            }
        }
        $this->logger->info("server host:".$this->host.'|'.$this->port);
    }