WokerTask/app/common/service/workerim/start_gateway.php

40 lines
957 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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();
}