启动界面:
# php start.php start -d
Workerman start in DAEMON mode
----------------------- WORKERMAN -----------------------------
Workerman version:3.1.8 PHP version:5.4.43
------------------------ WORKERS -------------------------------
user worker listen processes status
root ChatBusinessWorker none 1
root ChatGateway Websocket ://0.0.0.0:7272 1
root apptcp tcp ://0.0.0.0:55250 1
root WebServer http ://0.0.0.0:55151 2
----------------------------------------------------------------
Input "php start.php stop" to quit. Start success.
start_gateway.php 代码:
use \Workerman\Worker;
use \GatewayWorker\Gateway;
use \Workerman\Autoloader;
// 自动加载类
require_once __DIR__ . '/../../Workerman/Autoloader.php';
Autoloader::setRootPath(__DIR__);
// gateway 进程
$gateway = new Gateway("Websocket://0.0.0.0:7272");
// 设置名称,方便status时查看
$gateway->name = 'ChatGateway';
// 设置进程数,gateway进程数建议与cpu核数相同
$gateway->count = 1;
// 分布式部署时请设置成内网ip(非127.0.0.1)
$gateway->lanIp = '127.0.0.1';
// 内部通讯起始端口,假如$gateway->count=4,起始端口为4000
// 则一般会使用4001 4002 4003 4004 4个端口作为内部通讯端口
$gateway->startPort = 3000;
// 心跳间隔
$gateway->pingInterval = 2;
// 心跳数据
$gateway->pingData = '{"type":"ping"}';
// ########新增端口支持socket开始######
// 新增55250端口,开启socket连接
$gateway_text = new Gateway("tcp://0.0.0.0:55250");
// 进程名称,主要是status时方便识别
$gateway_text->name = 'apptcp';
// 开启多少text协议的gateway进程
$gateway_text->count = 1;
// 本机ip(分布式部署时需要设置成内网ip)
$gateway_text->lanIp = '127.0.0.1';
// gateway内部通讯起始端口,起始端口不要重复
$gateway_text->startPort = 2500;
// 心跳间隔
$gateway_text->pingInterval = 1;
$gateway_text->pingData = '{"type":"ping"}';
// 如果不是在根目录启动,则运行runAll方法
if(!defined('GLOBAL_START'))
{
Worker::runAll();
}
参考手册用抓包工具对55250端口抓没看到{"type":"ping"}