public function start()
    {
        $server = $this->createServerManager();

        // 是否正在运行
        if ($server->isRunning()) {
            $serverOpts = $server->getServerSetting();

            \output()->writeln("<error>The server have been running!(PID: {$serverOpts['masterPid']})</error>", true, true);
        } else {
            $serverOpts = $server->getServerSetting();
        }

        // 启动参数
        $this->configServer($server);
        $ws = $server->getWsSettings();
        $tcp = $server->getTcpSetting();

        // Setting
        $workerNum = $server->setting['worker_num'];

        // Ws(http) 启动参数
        $wsHost = $ws['host'];
        $wsPort = $ws['port'];
        $wsMode = $ws['mode'];
        $wsType = $ws['type'];
        $httpStatus = $ws['enable_http'] ? '<info>Enabled</info>' : '<warning>Disabled</warning>';

        // TCP 启动参数
        $tcpHost = $tcp['host'];
        $tcpPort = $tcp['port'];
        $tcpType = $tcp['type'];
        $tcpStatus = $serverOpts['tcpable'] ? '<info>Enabled</info>' : '<warning>Disabled</warning>';

        // 信息面板
        $lines = [
            '                                 Server Information                     ',
            '************************************************************************************',
            "* WS   | host: <note>$wsHost</note>, port: <note>$wsPort</note>, type: <note>$wsType</note>, worker: <note>$workerNum</note>, mode: <note>$wsMode</note> (http is $httpStatus)",
            "* TCP  | host: <note>$tcpHost</note>, port: <note>$tcpPort</note>, type: <note>$tcpType</note>, worker: <note>$workerNum</note> ($tcpStatus)",
            '************************************************************************************',
        ];

        // 启动服务器
        \output()->writeln(implode("\n", $lines));
        $server->start();
    }
public function start()
    {
        $server = $this->createServerManager();

        // 是否正在运行
        if ($server->isRunning()) {
            $serverOpts = $server->getServerSetting();

            \output()->writeln("<error>The server have been running!(PID: {$serverOpts['masterPid']})</error>", true, true);
        } else {
            $serverOpts = $server->getServerSetting();
        }

        // 启动参数
        $this->configServer($server);
        $ws = $server->getWsSettings();
        $tcp = $server->getTcpSetting();

        // Setting
        $workerNum = $server->setting['worker_num'];

        // Ws(http) 启动参数
        $wsHost = $ws['host'];
        $wsPort = $ws['port'];
        $wsMode = $ws['mode'];
        $wsType = $ws['type'];
        $httpStatus = $ws['enable_http'] ? '<info>Enabled</info>' : '<warning>Disabled</warning>';

        // TCP 启动参数
        $tcpHost = $tcp['host'];
        $tcpPort = $tcp['port'];
        $tcpType = $tcp['type'];
        $tcpStatus = $serverOpts['tcpable'] ? '<info>Enabled</info>' : '<warning>Disabled</warning>';

        // 信息面板
        $lines = [
            '                                 Server Information                     ',
            '************************************************************************************',
            "* WS   | host: <note>$wsHost</note>, port: <note>$wsPort</note>, type: <note>$wsType</note>, worker: <note>$workerNum</note>, mode: <note>$wsMode</note> (http is $httpStatus)",
            "* TCP  | host: <note>$tcpHost</note>, port: <note>$tcpPort</note>, type: <note>$tcpType</note>, worker: <note>$workerNum</note> ($tcpStatus)",
            '************************************************************************************',
        ];

        // 启动服务器
        \output()->writeln(implode("\n", $lines));
        $server->start();
    }
public function start ( ) { $ server = $ this -> createServerManager ( ) ; // 是否正在运行 if ( $ server -> isRunning ( ) ) { $ serverOpts = $ server -> getServerSetting ( ) ; \ output ( ) -> writeln ( "<error>The server have been running!(PID: {$serverOpts['masterPid']})</error>" , true , true ) ; } else { $ serverOpts = $ server -> getServerSetting ( ) ; } // 启动参数 $ this -> configServer ( $ server ) ; $ ws = $ server -> getWsSettings ( ) ; $ tcp = $ server -> getTcpSetting ( ) ; // Setting $ workerNum = $ server -> setting [ 'worker_num' ] ; // Ws(http) 启动参数 $ wsHost = $ ws [ 'host' ] ; $ wsPort = $ ws [ 'port' ] ; $ wsMode = $ ws [ 'mode' ] ; $ wsType = $ ws [ 'type' ] ; $ httpStatus = $ ws [ 'enable_http' ] ? '<info>Enabled</info>' : '<warning>Disabled</warning>' ; // TCP 启动参数 $ tcpHost = $ tcp [ 'host' ] ; $ tcpPort = $ tcp [ 'port' ] ; $ tcpType = $ tcp [ 'type' ] ; $ tcpStatus = $ serverOpts [ 'tcpable' ] ? '<info>Enabled</info>' : '<warning>Disabled</warning>' ; // 信息面板 $ lines = [ '                                 Server Information                     ' , '************************************************************************************' , "* WS   | host: <note>$wsHost</note>, port: <note>$wsPort</note>, type: <note>$wsType</note>, worker: <note>$workerNum</note>, mode: <note>$wsMode</note> (http is $httpStatus)" , "* TCP  | host: <note>$tcpHost</note>, port: <note>$tcpPort</note>, type: <note>$tcpType</note>, worker: <note>$workerNum</note> ($tcpStatus)" , '************************************************************************************' , ] ; // 启动服务器 \ output ( ) -> writeln ( implode ( "\n" , $ lines ) ) ; $ server -> start ( ) ; }
Start the webSocket server

@Usage {fullCommand} [-d|--daemon]
@Options
-d, --daemon    Run server on the background
@Example
{fullCommand}
{fullCommand} -d
@throws \InvalidArgumentException
@throws \Swoft\Exception\RuntimeException
@throws \RuntimeException
Start the webSocket server