40 lines
957 B
PHP
40 lines
957 B
PHP
|
<?php
|
|||
|
|
|||
|
use \Workerman\Worker;
|
|||
|
use \GatewayWorker\Gateway;
|
|||
|
|
|||
|
// 自动加载类
|
|||
|
require_once __DIR__ . '/../../../../vendor/autoload.php';
|
|||
|
|
|||
|
// gateway 进程,这里使用Text协议,可以用telnet测试
|
|||
|
$gateway = new Gateway("Websocket://0.0.0.0:8282");
|
|||
|
|
|||
|
// gateway名称,status方便查看
|
|||
|
$gateway->name = 'worker_task_im';
|
|||
|
|
|||
|
// gateway进程数,一般设置2个就足够
|
|||
|
$gateway->count = 4;
|
|||
|
|
|||
|
// 本机ip,分布式部署时使用内网ip
|
|||
|
$gateway->lanIp = '172.19.97.179';
|
|||
|
|
|||
|
// 内部通讯起始端口,假如$gateway->count=2,起始端口为2900
|
|||
|
// 则一般会使用3900 3901 3902 3903 4个端口作为内部通讯端口
|
|||
|
$gateway->startPort = 3900;
|
|||
|
|
|||
|
// 服务注册地址
|
|||
|
$gateway->registerAddress = '172.19.97.179:1256';
|
|||
|
|
|||
|
// 心跳间隔
|
|||
|
$gateway->pingInterval = 20;
|
|||
|
|
|||
|
// 心跳数据
|
|||
|
$gateway->pingData = '{"type":"ping"}';
|
|||
|
|
|||
|
// 如果不是在根目录启动,则运行runAll方法
|
|||
|
if(!defined('GLOBAL_START'))
|
|||
|
{
|
|||
|
Worker::runAll();
|
|||
|
}
|
|||
|
|