多个businessWorker放在同一个控制器方法中启动,会不会影响性能

alpha

问题描述

<?php

namespace app\admin\controller;

use GatewayWorker\BusinessWorker;
use Workerman\Worker;

//require '../extend/GlobalData-master/src/Client.php';

class GateWayBusinessWorker
{
    public function index()
    {
        //businessWorker 进程
        $worker = new BusinessWorker();
        //worker 名称
        $worker->name = 'TpWorkBusinessWorker';
        $worker->count = Cfg::tp_business_count;
        // 服务注册地址
        $worker->registerAddress = '127.0.0.1:' . Cfg::tp_register_port;
        $worker->eventHandler    = '\app\admin\controller\GateWayEvents';

        //分类:log
        $worker_log                  = new BusinessWorker();
        $worker_log->name            = 'TpWorkBusinessWorker_log';
        $worker_log->count           = 1;
        $worker_log->registerAddress = '127.0.0.1:' . Cfg::tp_log_register_port;
        $worker_log->eventHandler    = '\app\admin\controller\GateWayEventsLog';

        // 如果不是在根目录启动,则运行 runAll 方法
        if ( !defined( 'TP_GLOBAL_START' ) ) {
            // 启用swoole的事件驱动
            Worker::$eventLoopClass = 'Workerman\Events\Swoole';

            Worker::runAll();
        }
    }
}

截图
启动后是这样的,这样放一起会不会影响性能,还是分开启动好?

538 3 0
3个回答

Tinywan

没看懂,这是什么骚操作

  • 暂无评论
turbo

我也没看懂,为什么有这种操作

  • liong 2024-01-31

    这么做的目的是什么

liong

这么做的目的是什么

  • 暂无评论
×
🔝