@@ -15,15 +15,17 @@ jobs:
1515 - name : Check lanlan.app (old)
1616 id : check_app
1717 run : |
18+ CURL_EXIT=0
1819 HTTP_CODE=$(curl -s -o /tmp/resp_app.json -w "%{http_code}" \
1920 --max-time 30 --connect-timeout 10 \
2021 -X POST "https://lanlan.app/text/v1/chat/completions" \
2122 -H "Content-Type: application/json" \
2223 -H "Authorization: Bearer free-access" \
2324 -d '{"model":"free-mini-model","messages":[{"role":"user","content":"sends some useful information"}],"max_completion_tokens":5}' \
24- 2>/dev/null || echo "000")
25+ 2>/dev/null) || CURL_EXIT=$?
2526 BODY=$(cat /tmp/resp_app.json 2>/dev/null || echo "{}")
2627 echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
28+ echo "curl_exit=$CURL_EXIT" >> "$GITHUB_OUTPUT"
2729
2830 if [ "$HTTP_CODE" = "200" ]; then
2931 if echo "$BODY" | jq -e '(.choices | type) == "array" and (.choices | length) > 0 and (.choices[0].message | type) == "object" and .choices[0].message.role == "assistant" and (.choices[0].message | has("content"))' >/dev/null 2>&1; then
@@ -39,15 +41,17 @@ jobs:
3941 - name : Check www.lanlan.app (new)
4042 id : check_api_app
4143 run : |
44+ CURL_EXIT=0
4245 HTTP_CODE=$(curl -s -o /tmp/resp_api_app.json -w "%{http_code}" \
4346 --max-time 30 --connect-timeout 10 \
4447 -X POST "https://www.lanlan.app/text/v1/chat/completions" \
4548 -H "Content-Type: application/json" \
4649 -H "Authorization: Bearer free-access" \
4750 -d '{"model":"free-mini-model","messages":[{"role":"user","content":"sends some useful information"}],"max_completion_tokens":5}' \
48- 2>/dev/null || echo "000")
51+ 2>/dev/null) || CURL_EXIT=$?
4952 BODY=$(cat /tmp/resp_api_app.json 2>/dev/null || echo "{}")
5053 echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
54+ echo "curl_exit=$CURL_EXIT" >> "$GITHUB_OUTPUT"
5155
5256 if [ "$HTTP_CODE" = "200" ]; then
5357 if echo "$BODY" | jq -e '(.choices | type) == "array" and (.choices | length) > 0 and (.choices[0].message | type) == "object" and .choices[0].message.role == "assistant" and (.choices[0].message | has("content"))' >/dev/null 2>&1; then
@@ -63,15 +67,17 @@ jobs:
6367 - name : Check www.lanlan.tech (new)
6468 id : check_api_tech
6569 run : |
70+ CURL_EXIT=0
6671 HTTP_CODE=$(curl -s -o /tmp/resp_api_tech.json -w "%{http_code}" \
6772 --max-time 30 --connect-timeout 10 \
6873 -X POST "https://www.lanlan.tech/text/v1/chat/completions" \
6974 -H "Content-Type: application/json" \
7075 -H "Authorization: Bearer free-access" \
7176 -d '{"model":"free-mini-model","messages":[{"role":"user","content":"sends some useful information"}],"max_completion_tokens":5}' \
72- 2>/dev/null || echo "000")
77+ 2>/dev/null) || CURL_EXIT=$?
7378 BODY=$(cat /tmp/resp_api_tech.json 2>/dev/null || echo "{}")
7479 echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
80+ echo "curl_exit=$CURL_EXIT" >> "$GITHUB_OUTPUT"
7581
7682 if [ "$HTTP_CODE" = "200" ]; then
7783 if echo "$BODY" | jq -e '(.choices | type) == "array" and (.choices | length) > 0 and (.choices[0].message | type) == "object" and .choices[0].message.role == "assistant" and (.choices[0].message | has("content"))' >/dev/null 2>&1; then
@@ -99,6 +105,22 @@ jobs:
99105 API_APP_CODE="${{ steps.check_api_app.outputs.http_code }}"
100106 API_TECH_CODE="${{ steps.check_api_tech.outputs.http_code }}"
101107
108+ APP_EXIT="${{ steps.check_app.outputs.curl_exit }}"
109+ API_APP_EXIT="${{ steps.check_api_app.outputs.curl_exit }}"
110+ API_TECH_EXIT="${{ steps.check_api_tech.outputs.curl_exit }}"
111+
112+ # curl 退出码非零(拿不到响应、即 http_code=000)时附带退出码(28=超时, 7=拒连, 6=DNS, 35=TLS)以区分故障类型
113+ fmt_code() {
114+ if [ -n "$2" ] && [ "$2" != "0" ]; then
115+ echo "$1, curl exit $2"
116+ else
117+ echo "$1"
118+ fi
119+ }
120+ APP_CODE_DISP=$(fmt_code "$APP_CODE" "$APP_EXIT")
121+ API_APP_CODE_DISP=$(fmt_code "$API_APP_CODE" "$API_APP_EXIT")
122+ API_TECH_CODE_DISP=$(fmt_code "$API_TECH_CODE" "$API_TECH_EXIT")
123+
102124 ALL_HEALTHY="true"
103125 ANY_DOWN="false"
104126 for h in "$APP_HEALTHY" "$API_APP_HEALTHY" "$API_TECH_HEALTHY"; do
@@ -120,21 +142,21 @@ jobs:
120142 fi
121143
122144 if [ "$APP_HEALTHY" = "true" ]; then
123- APP_STATUS=":white_check_mark: OK (HTTP $APP_CODE )"
145+ APP_STATUS=":white_check_mark: OK (HTTP $APP_CODE_DISP )"
124146 else
125- APP_STATUS=":x: DOWN (HTTP $APP_CODE )"
147+ APP_STATUS=":x: DOWN (HTTP $APP_CODE_DISP )"
126148 fi
127149
128150 if [ "$API_APP_HEALTHY" = "true" ]; then
129- API_APP_STATUS=":white_check_mark: OK (HTTP $API_APP_CODE )"
151+ API_APP_STATUS=":white_check_mark: OK (HTTP $API_APP_CODE_DISP )"
130152 else
131- API_APP_STATUS=":x: DOWN (HTTP $API_APP_CODE )"
153+ API_APP_STATUS=":x: DOWN (HTTP $API_APP_CODE_DISP )"
132154 fi
133155
134156 if [ "$API_TECH_HEALTHY" = "true" ]; then
135- API_TECH_STATUS=":white_check_mark: OK (HTTP $API_TECH_CODE )"
157+ API_TECH_STATUS=":white_check_mark: OK (HTTP $API_TECH_CODE_DISP )"
136158 else
137- API_TECH_STATUS=":x: DOWN (HTTP $API_TECH_CODE )"
159+ API_TECH_STATUS=":x: DOWN (HTTP $API_TECH_CODE_DISP )"
138160 fi
139161
140162 # 只在有故障时 @everyone
0 commit comments