webman 运行多个gateway-worker的问题,第一个我装的插件,通过配置使用.那第二个怎么配置呢?通过框架启动的方式是不是只能用一个,另一个单独启动(已解決)

Gin

把 config/plugin/gatewaw-worker 复制一份方同级目录 改改端口配置及 Events位置即可

838 3 0
3个回答

不败少龙

要配置多个协议吗?还是要用一个event.php这个文件

  • Gin 2022-10-10

    看我下方截图, 改的地方圈住了

Gin

截图

不败少龙
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,
            'pingData'        => '{"type":"ping"}',
            '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://0.0.0.0:1236',
        'count'       => 1, // Must be 1
        'constructor' => []
    ],
    'gatewayTCP' => [
        'handler'     => Gateway::class,
        'listen'      => 'tcp://0.0.0.0:7070',
        'count'       => cpu_count(),
        'reloadable'  => false,
        'constructor' => ['config' => [
            'lanIp'           => '127.0.0.1',
            'startPort'       => 4100,
            'pingInterval'    => 25,
            'pingData'        => '{"type":"ping"}',
            'registerAddress' => '127.0.0.1:1236',
            'onConnect'       => function(){},
        ]]
    ],
];
  • Gin 2022-10-10

    你这样也可以, 共用一个Events.php 如果业务逻辑没啥交集的话, 单独处理我感觉比较好

年代过于久远,无法发表回答
×
🔝