【已解决】webman结合gatewayWorker后能有多个events吗

fantasmic

问题描述

一个项目中能在process中配置多个gateway、worker、register吗?
想的是有多个业务进程

为此你搜索到了哪些方案及不适用的原因

大意了,端口还没改到

645 3 1
3个回答

清梦独行

怎么配置的。方便贴一下代码吗,我也有这个需求,webman里面配置两个gateway

  • 暂无评论
meows

讲道理应该可以

  • 暂无评论
fantasmic

就是多复制一下3个配置

<?php

use Webman\GatewayWorker\Gateway;
use Webman\GatewayWorker\BusinessWorker;
use Webman\GatewayWorker\Register;

return [
    'gateway' => [
        'handler'     => Gateway::class,
        'listen'      => 'websocket://0.0.0.0:7272',
        'count'       => cpu_count(),
        'reloadable'  => false,
        'constructor' => ['config' => [
            'lanIp'           => '127.0.0.1',
            'startPort'       => 2300,
            'pingInterval'    => 25,
            'pingNotResponseLimit' => 1,
            'pingData'        => '',
            'registerAddress' => '127.0.0.1:1236',
            'onConnect'       => function(){},
        ]]
    ],
    'worker' => [
        'handler'     => BusinessWorker::class,
        'count'       => cpu_count()*2,
        'constructor' => ['config' => [
            'eventHandler'    => plugin\webman\gateway\Events::class,
            'name'            => 'ChatBusinessWorker',
            'registerAddress' => '127.0.0.1:1236',
        ]]
    ],
    'register' => [
        'handler'     => Register::class,
        'listen'      => 'text://127.0.0.1:1236',
        'count'       => 1, // Must be 1
        'constructor' => []
    ],

    'gateway_demo' => [
        'handler'     => Gateway::class,
        'listen'      => 'websocket://0.0.0.0:7373',
        'count'       => cpu_count(),
        'reloadable'  => false,
        'constructor' => ['config' => [
            'lanIp'           => '127.0.0.1',
            'startPort'       => 2400,
            'pingInterval'    => 25,
            'pingNotResponseLimit' => 1,
            'pingData'        => '',
            'registerAddress' => '127.0.0.1:1237',
            'onConnect'       => function(){},
        ]]
    ],
    'worker_demo' => [
        'handler'     => BusinessWorker::class,
        'count'       => cpu_count()*2,
        'constructor' => ['config' => [
            'eventHandler'    => plugin\webman\gateway\Demo::class,
            'name'            => 'worker_demo',
            'registerAddress' => '127.0.0.1:1237',
        ]]
    ],
    'register_demo' => [
        'handler'     => Register::class,
        'listen'      => 'text://127.0.0.1:1237',
        'count'       => 1, // Must be 1
        'constructor' => []
    ],
];
年代过于久远,无法发表回答
×
🔝