工作台优化

This commit is contained in:
wong
2025-05-21 15:48:21 +08:00
parent cd4aea75cf
commit a668a0a55b

View File

@@ -196,8 +196,9 @@ class WorkbenchJob
return;
}
// 将好友列表分成10组
// 将好友列表分成20组
$friendGroups = array_chunk($friendList, 10);
$processes = [];
foreach ($friendGroups as $groupIndex => $friendGroup) {
@@ -214,11 +215,9 @@ class WorkbenchJob
} else {
// 子进程
try {
// 重置数据库连接
Db::close();
Db::init();
foreach ($friendGroup as $friend) {
Log::info("我是一个工作台子进程");
// 验证是否达到点赞次数上限
$likeCount = $this->getTodayLikeCount($workbench, $config, $friend['deviceId']);
if ($likeCount >= $config['maxLikes']) {
@@ -233,14 +232,12 @@ class WorkbenchJob
->count();
if ($friendMaxLikes < $config['friendMaxLikes']) {
Log::info("工作台 {$workbench->id} 开始处理好友 {$friend['friendId']} 的朋友圈");
$this->processFriendMoments($workbench, $config, $friend);
}
}
} catch (\Exception $e) {
Log::error("工作台 {$workbench->id} 子进程异常: " . $e->getMessage());
} finally {
// 确保关闭数据库连接
Db::close();
}
// 子进程执行完毕后退出