写了个定时器,日志却在不停的增长

sbdx

代码基本上是仿照文档写的。

$room_config=array();
$task = new Worker();
$task->count = 1;
$task->onWorkerStart = function($task)
{
    global $room_config;
    ReloadRoomConfig();
    //定时检测房间设置
    $check_room_interval = 30;
    Timer::add($check_room_interval, function() use (&$room_config)
    {
        info('ReLoad Room Setting ...');
        ReloadRoomConfig();
    });

    //聊天机器人
    Timer::add(1,function() use (&$room_config)
    {
        //处理随机聊天业务
    });
};

Worker::runAll();

调试模式很好,但是用-d模式日志一直在增长,不知道为什么。

#tail -f workman.log
2018-06-19 01:04:19 pid:30443 Worker process terminated
2018-06-19 01:04:19 pid:30444 Worker process terminated
2018-06-19 01:04:19 pid:30445 Worker process terminated
2018-06-19 01:04:19 pid:30446 Worker process terminated
2018-06-19 01:04:19 pid:30447 Worker process terminated
2018-06-19 01:04:19 pid:30448 Worker process terminated
2018-06-19 01:04:19 pid:30449 Worker process terminated
2018-06-19 01:04:19 pid:30450 Worker process terminated
2018-06-19 01:04:19 pid:30451 Worker process terminated
不断循环...
3274 2 0
2个回答

walkor 打赏

数据库 redis等资源在onWorkerStart里初始化,不要在启动脚本里直接初始化。

  • 暂无评论
sbdx

OK,果然放到onWorkerStart就没问题了,谢谢@walkor

  • 暂无评论
年代过于久远,无法发表回答
×
🔝