This commit is contained in:
weiz 2023-10-21 11:56:43 +08:00
parent 00f49b08f0
commit 0eb6d8607d
7 changed files with 19 additions and 18 deletions

View File

@ -17,7 +17,7 @@ class ImController extends BaseLikeAdminController
public function __construct(App $app) public function __construct(App $app)
{ {
parent::__construct($app); parent::__construct($app);
Gateway::$registerAddress = "172.19.97.179:1256"; Gateway::$registerAddress = env('worker.address').':'.env('worker.port');
} }
//获取场景值 //获取场景值

View File

@ -1,7 +1,8 @@
<?php <?php
namespace workerim; namespace app\common\service\workerim;
use GatewayClient\Gateway; use GatewayClient\Gateway;
/** /**
* 主逻辑 * 主逻辑
* 主要是处理 onConnect onMessage onClose 三个方法 * 主要是处理 onConnect onMessage onClose 三个方法

View File

@ -1,11 +1,11 @@
<?php <?php
use \Workerman\Worker; use GatewayWorker\BusinessWorker;
use \GatewayWorker\BusinessWorker; use Workerman\Worker;
// 自动加载类 // 自动加载类
require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../../../../vendor/autoload.php';
// bussinessWorker 进程 // bussinessWorker 进程
$worker = new BusinessWorker(); $worker = new BusinessWorker();
@ -17,10 +17,10 @@ $worker->name = 'PushBusinessWorker';
$worker->count = 4; $worker->count = 4;
// 服务注册地址 // 服务注册地址
$worker->registerAddress = '172.19.97.179:1256'; $worker->registerAddress = env('worker.address').':'.env('worker.port');
// 注册服务类 // 注册服务类
$worker->eventHandler = 'workerim\Events'; $worker->eventHandler = 'app\common\service\workerim\Events';
// 如果不是在根目录启动则运行runAll方法 // 如果不是在根目录启动则运行runAll方法
if(!defined('GLOBAL_START')) if(!defined('GLOBAL_START'))

View File

@ -4,26 +4,26 @@ use \Workerman\Worker;
use \GatewayWorker\Gateway; use \GatewayWorker\Gateway;
// 自动加载类 // 自动加载类
require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../../../../vendor/autoload.php';
// gateway 进程这里使用Text协议可以用telnet测试 // gateway 进程这里使用Text协议可以用telnet测试
$gateway = new Gateway("Websocket://0.0.0.0:8282"); $gateway = new Gateway("Websocket://0.0.0.0:8282");
// gateway名称status方便查看 // gateway名称status方便查看
$gateway->name = 'worker_task_im'; $gateway->name = env('worker.work_name');
// gateway进程数一般设置2个就足够 // gateway进程数一般设置2个就足够
$gateway->count = 4; $gateway->count = 4;
// 本机ip分布式部署时使用内网ip // 本机ip分布式部署时使用内网ip
$gateway->lanIp = '172.19.97.179'; $gateway->lanIp = env('worker.address');
// 内部通讯起始端口,假如$gateway->count=2起始端口为2900 // 内部通讯起始端口,假如$gateway->count=2起始端口为2900
// 则一般会使用3900 3901 3902 3903 4个端口作为内部通讯端口 // 则一般会使用3900 3901 3902 3903 4个端口作为内部通讯端口
$gateway->startPort = 3900; $gateway->startPort = env('worker.start_port');
// 服务注册地址 // 服务注册地址
$gateway->registerAddress = '172.19.97.179:1256'; $gateway->registerAddress = env('worker.address').':'.env('worker.port');
// 心跳间隔 // 心跳间隔
$gateway->pingInterval = 20; $gateway->pingInterval = 20;

View File

@ -3,10 +3,10 @@ use \Workerman\Worker;
use \GatewayWorker\Register; use \GatewayWorker\Register;
// 自动加载类 // 自动加载类
require_once __DIR__ . '/../../vendor/autoload.php'; require_once __DIR__ . '/../../../../vendor/autoload.php';
// register 必须是text协议切记不能将register端口开放给外网 // register 必须是text协议切记不能将register端口开放给外网
$register = new Register('text://172.19.97.179:1256'); $register = new Register('text://'.env('worker.address').':'.env('worker.port'));
// 如果不是在根目录启动则运行runAll方法 // 如果不是在根目录启动则运行runAll方法
if(!defined('GLOBAL_START')) if(!defined('GLOBAL_START'))

View File

@ -29,7 +29,7 @@ define('GLOBAL_START', 1);
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';
// 加载所有Applications/*/start.php以便启动所有服务 // 加载所有Applications/*/start.php以便启动所有服务
foreach(glob(__DIR__.'/extend/workerim/start*.php') as $start_file) foreach(glob(__DIR__.'/app/common/service/workerim/start*.php') as $start_file)
{ {
require_once $start_file; require_once $start_file;
} }

View File

@ -1,3 +1,3 @@
CHCP 65001 CHCP 65001
php extend\workerim\start_register.php extend\workerim\start_gateway.php extend\workerim\start_businessworker.php php app\common\service\workerim\start_register.php app\common\service\workerim\start_gateway.php app\common\service\workerim\start_businessworker.php
pause pause