正在显示
1 个修改的文件
包含
22 行增加
和
0 行删除
| @@ -60,7 +60,29 @@ class FetchTicketProjects extends Command | @@ -60,7 +60,29 @@ class FetchTicketProjects extends Command | ||
| 60 | $postids = []; | 60 | $postids = []; |
| 61 | 61 | ||
| 62 | while (true) { | 62 | while (true) { |
| 63 | + try { | ||
| 64 | + $maxRetries = 3; | ||
| 65 | + $retryCount = 0; | ||
| 66 | + | ||
| 67 | + while ($retryCount < $maxRetries) { | ||
| 68 | + try { | ||
| 63 | $response = Http::get('https://www.quanqiusou.cn/extend_api/webs/globalso_all.php?page=' . $page); | 69 | $response = Http::get('https://www.quanqiusou.cn/extend_api/webs/globalso_all.php?page=' . $page); |
| 70 | + break; // 如果请求成功,跳出重试循环 | ||
| 71 | + } catch (\Exception $e) { | ||
| 72 | + $retryCount++; | ||
| 73 | + if ($retryCount >= $maxRetries) { | ||
| 74 | + // 如果达到最大重试次数,抛出异常 | ||
| 75 | + throw $e; | ||
| 76 | + } | ||
| 77 | + // 等待一段时间再重试 | ||
| 78 | + sleep(2); | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + }catch (\Exception $e){ | ||
| 82 | + echo now() . " | ERROR | " . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n"; | ||
| 83 | + break; | ||
| 84 | + } | ||
| 85 | + | ||
| 64 | if ($response->status() == 200) { | 86 | if ($response->status() == 200) { |
| 65 | $resp_json = $response->json(); | 87 | $resp_json = $response->json(); |
| 66 | $items = $resp_json['data'] ?? []; | 88 | $items = $resp_json['data'] ?? []; |
-
请 注册 或 登录 后发表评论