平滑加载一直无效,请大神解惑,谢谢!

xinsnd

Applications/YourApp/start_businessworker.php代码:

<?php 
...

require_once __DIR__ . '/../../vendor/autoload.php';
$worker = new BusinessWorker();
$worker->name = 'YourAppBusinessWorker';
$worker->count = 4;

$worker->registerAddress = '127.0.0.1:1238';
$worker->reloadable = true;
$worker->onWorkerStart = function($worker) {
    require __DIR__ . '/../Trans/Trans.php';   //动态加载
};

if(!defined('GLOBAL_START'))
{
    Worker::runAll();
}

在Events.php的onMessage()中测试:

   public static function onMessage($client_id, $message)
   {

       Trans::test($message);
   }

Trans.php 代码:

<?php
namespace Applications\Trans;
class Trans
{
    public static function test($msg){
        if($msg){
            echo "\n$msg!----------------%%&";
        }
    }
}
1990 1 0
1个回答

walkor 打赏

可能是开了opcache。
运行 php -i | grep opcache.enable_cli 如果显示为on,打开 php.ini 将opcache.enable_cli其修改为 0。
restart重启再试下。

  • xinsnd 2021-01-23

    高人!问题解决了,非常感谢!

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