refactor(timer): 使用 CurlMultiHandler 替代 Workerman,统一为非阻塞模式

- 删除 runParallel() 方法和所有 Workerman 引用(死代码)
- 重写 runLoop() 为 Guzzle CurlMultiHandler 非阻塞事件循环
- 新增 pending 数组追踪进行中的请求,handler.tick() 非阻塞推进
- 自适应 sleep 策略(有任务 50ms,空闲 200ms)
- 简化 config/timer.php:移除 mode,适配 Guzzle 参数
- 更新 SKILL.md:移除 parallel 描述,修正 --quit 文档 bug
- 验证发现:--quiet 是 ThinkPHP 全局选项,不需要在 configure() 注册
- 验证发现:方法名不能用 run(),与 ThinkPHP Command::run() 签名冲突
This commit is contained in:
augushong
2026-06-02 21:19:53 +08:00
parent c4fbd60bbc
commit 76b23d4c70
3 changed files with 81 additions and 144 deletions

View File

@@ -2,18 +2,18 @@
use think\facade\Env;
// 配置参考https://doc.ulthon.com/read/augushong/ulthon_admin/timer-mode/zh-cn/2.x.html
// 定时器配置Guzzle CurlMultiHandler 非阻塞模式)
$config = [
'mode' => 'normal',
// Guzzle Client 连接配置
'connect_timeout' => 30, // 连接超时时间(秒)
'timeout' => 86400, // 请求响应超时时间(秒)
// 目前仅对多进程模式生效暂不支持设置为0不限制
'max_conn_per_addr' => 128, // 每个域名最多维持多少并发连接
'keepalive_timeout' => 86400, // 连接多长时间不通讯就关闭
'connect_timeout' => 86400, // 连接超时时间
'timeout' => 86400, // 请求发出后等待响应的超时时间
// CurlMultiHandler 配置
'max_handles' => 100, // curl multi 最大并发句柄数
'select_timeout' => 0.001, // curl_multi_select 超时(秒)
// 清理日志保留天数debug_log 表)
'clear_log_days' => Env::get('timer.clear_log_days', 3),
'clear_log_days' => Env::get('timer.clear_log_days', 3),
];
return $config;