[split-upload 2/6] f2fd4fa backup via proxy

This commit is contained in:
Simon
2026-08-11 14:16:24 +08:00
parent 268bf914ce
commit e54529d307
74 changed files with 5450 additions and 65 deletions
+2
View File
@@ -0,0 +1,2 @@
-- 查询坐席状态
SELECT id, name, status FROM agents;
+84
View File
@@ -0,0 +1,84 @@
#!/bin/bash
# =============================================================================
# /itdesk/ 500 错误诊断脚本
# 在生产服务器 10.90.5.110 上跑(PuTTY 登录后):
# cd /opt/wecom-it-desk
# bash diagnose-500.sh > /tmp/diag.log 2>&1
# cat /tmp/diag.log
# =============================================================================
echo "========== 1. 容器状态 =========="
docker compose ps
echo ""
echo "========== 2. /opt/wecom-it-desk 目录结构 =========="
ls -la /opt/wecom-it-desk/ 2>&1 | head -20
echo "--- frontend-h5/dist ---"
ls -la /opt/wecom-it-desk/frontend-h5/dist/ 2>&1 | head -10
echo "--- frontend-h5/dist/assets ---"
ls -la /opt/wecom-it-desk/frontend-h5/dist/assets/ 2>&1 | head -10
echo "--- frontend-agent/dist/assets ---"
ls -la /opt/wecom-it-desk/frontend-agent/dist/assets/ 2>&1 | head -10
echo "--- frontend-portal/dist/assets ---"
ls -la /opt/wecom-it-desk/frontend-portal/dist/assets/ 2>&1 | head -10
echo "--- frontend-admin/dist/assets ---"
ls -la /opt/wecom-it-desk/frontend-admin/dist/assets/ 2>&1 | head -10
echo ""
echo "========== 3. nginx 容器内文件检查 =========="
docker compose exec nginx ls -la /usr/share/nginx/html/ 2>&1 | head -20
echo "--- /usr/share/nginx/html/itdesk ---"
docker compose exec nginx ls -la /usr/share/nginx/html/itdesk/ 2>&1 | head -10
echo "--- /usr/share/nginx/html/itdesk/assets ---"
docker compose exec nginx ls -la /usr/share/nginx/html/itdesk/assets/ 2>&1 | head -10
echo "--- /usr/share/nginx/ssl/ ---"
docker compose exec nginx ls -la /etc/nginx/ssl/ 2>&1 | head -10
echo ""
echo "========== 4. nginx 配置实际生效版本(头部 50 行)=========="
docker compose exec nginx cat /etc/nginx/nginx.conf 2>&1 | head -50
echo ""
echo "========== 5. nginx 容器端口监听 =========="
docker compose exec nginx netstat -tlnp 2>&1 | head -10
echo "(没 netstat 用 ss:)"
docker compose exec nginx ss -tlnp 2>&1 | head -10
echo ""
echo "========== 6. 直接 curl 测试各路径 =========="
echo "--- /itdesk/ (容器内) ---"
docker compose exec nginx curl -ksI https://localhost/itdesk/ 2>&1 | head -20
echo "--- /itdesk/ (容器外主机 443) ---"
curl -ksI https://localhost:443/itdesk/ 2>&1 | head -20
echo "--- /itportal/ ---"
curl -ksI https://localhost:443/itportal/ 2>&1 | head -20
echo "--- /itdesk/assets/ (探 404) ---"
curl -ksI https://localhost:443/itdesk/assets/ 2>&1 | head -20
echo ""
echo "========== 7. 主机实际 URL 域名 =========="
curl -ksI https://itsupport.servyou.com.cn/itdesk/ 2>&1 | head -20
echo "---"
curl -ksI https://itsupport.servyou.com.cn/itportal/ 2>&1 | head -20
echo "---"
curl -ksI https://itsupport.servyou.com.cn/itagent/ 2>&1 | head -20
echo "---"
curl -ksI https://itsupport.servyou.com.cn/itadmin/ 2>&1 | head -20
echo ""
echo "========== 8. nginx access log 最近 30 行(找 500 请求)=========="
docker compose exec nginx tail -30 /var/log/nginx/access.log 2>&1
echo ""
echo "========== 9. nginx error log 最近 30 行 =========="
docker compose exec nginx tail -30 /var/log/nginx/error.log 2>&1
echo ""
echo "========== 10. backend 容器健康 =========="
docker compose ps backend
echo "--- backend health endpoint ---"
docker compose exec backend curl -ks http://localhost:8000/api/health 2>&1 | head -5
echo ""
echo "========== 11. 看一下后端访问 /api/h5/me (H5 启动时会调)=========="
echo "--- /api/h5/me 无 token ---"
curl -ks -i -X GET https://itsupport.servyou.com.cn/api/h5/me 2>&1 | head -10
+43
View File
@@ -0,0 +1,43 @@
# NAS /volume1/ directory listing scan script
# Double-click or run in PowerShell, lists all top-level dirs with sizes
$ErrorActionPreference = "Continue"
$outputFile = "$PSScriptRoot\nas_volumes.txt"
# Force UTF-8 console encoding for SSH output
chcp 65001 | Out-Null
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
Write-Host "===================================" -ForegroundColor Cyan
Write-Host " NAS /volume1/ Directory Scan" -ForegroundColor Cyan
Write-Host "===================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Scanning... du on large dirs may take 1-3 minutes" -ForegroundColor Yellow
Write-Host ""
$cmd = @"
echo '===== Top-level dirs in /volume1/ ====='
ls -la /volume1/ 2>&1 | grep -v '^total'
echo ''
echo '===== Size by dir (largest first, may take minutes) ====='
du -sh /volume1/*/ 2>/dev/null | sort -rh
echo ''
echo '===== /volume1/homes/ ====='
ls -la /volume1/homes/ 2>/dev/null | head -20
echo ''
echo '===== /volume1/homes/simon/ content ====='
ls -la /volume1/homes/simon/ 2>/dev/null | head -30
du -sh /volume1/homes/simon/*/ 2>/dev/null | sort -rh | head -20
echo ''
echo '===== DONE ====='
"@
ssh simon@100.85.152.112 $cmd 2>&1 | Tee-Object -FilePath $outputFile -Encoding UTF8
Write-Host ""
Write-Host "===================================" -ForegroundColor Green
Write-Host " Done. Output saved to:" -ForegroundColor Green
Write-Host " $outputFile" -ForegroundColor White
Write-Host "===================================" -ForegroundColor Green
Write-Host ""
Read-Host "Press Enter to close"
+1
View File
@@ -0,0 +1 @@
UPDATE agents SET status = 'offline' WHERE id = 'agent-sxn-001';
+3
View File
@@ -0,0 +1,3 @@
import requests
r = requests.get('http://127.0.0.1:8000/h5/agents/online-status')
print(r.text)
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""Test detect-intent API from inside backend container (direct FastAPI)."""
import json
import httpx
# Backend FastAPI listens on 8000 inside the container
url = "http://localhost:8000/api/approval/detect-intent"
test_messages = [
"我要申请VPN",
"我的电脑坏了",
"我要申请办公用品",
"你好,今天天气怎么样?",
]
for msg in test_messages:
print(f"\n=== Testing: {msg} ===")
try:
resp = httpx.post(
url,
json={"text": msg},
timeout=30.0,
)
print(f" HTTP: {resp.status_code}")
print(f" Response: {resp.text[:500]}")
if resp.status_code == 200:
data = resp.json()
result = data.get("data", data)
print(f" is_approval: {result.get('is_approval_request')}")
print(f" confidence: {result.get('confidence')}")
print(f" type: {result.get('approval_type')}")
print(f" source: {result.get('source')}")
except Exception as e:
print(f" ERROR: {type(e).__name__}: {e}")
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env python3
"""测试 Dify DNS 解析"""
import socket
host = "yw-dify.dc.servyou-it.com"
try:
ip = socket.gethostbyname(host)
print(f"{host} -> {ip}")
except Exception as e:
print(f"DNS lookup failed: {e}")
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
"""测试 Dify 原生 API 和 dify2openai 代理"""
import httpx
import asyncio
async def test_dify():
async with httpx.AsyncClient(timeout=30) as client:
# 1. 测试原生 API 路径
print("=== Test 1: Dify Native API (v1/chat-messages) ===")
url1 = "http://yw-dify.dc.servyou-it.com/v1/chat-messages"
headers1 = {
"Authorization": "Bearer app-7jkRkAzvX4QM9v9SM3P8mMEO",
"Content-Type": "application/json"
}
payload1 = {
"inputs": {"user_query": "hello"},
"query": "hello",
"response_mode": "blocking",
"user": "test-user-001"
}
try:
r1 = await client.post(url1, json=payload1, headers=headers1)
print(f"Status: {r1.status_code}")
print(f"Response: {r1.text[:300]}")
except Exception as e:
print(f"Error: {e}")
print()
# 2. 测试 dify2openai 代理路径
print("=== Test 2: dify2openai Proxy ===")
url2 = "http://yw-dify.dc.servyou-it.com/dify2openai/v1/chat/completions"
headers2 = {
"Authorization": "Bearer http://yw-dify.dc.servyou-it.com/v1|app-7jkRkAzvX4QM9v9SM3P8mMEO|Chat",
"Content-Type": "application/json"
}
payload2 = {
"model": "Chat",
"messages": [{"role": "user", "content": "hello"}],
"stream": False
}
try:
r2 = await client.post(url2, json=payload2, headers=headers2)
print(f"Status: {r2.status_code}")
print(f"Response: {r2.text[:300]}")
except Exception as e:
print(f"Error: {e}")
print()
# 3. 测试 Dify 健康检查
print("=== Test 3: Dify Health Check ===")
try:
r3 = await client.get("http://yw-dify.dc.servyou-it.com/")
print(f"Status: {r3.status_code}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
asyncio.run(test_dify())
+9
View File
@@ -0,0 +1,9 @@
import sys
sys.path.insert(0, 'backend')
from app.services.asset_recommend_service import AssetRecommendService
svc = AssetRecommendService()
cards = svc.match_keywords('VPN连不上怎么办')
print(f'Found {len(cards)} cards')
for c in cards:
print(f' - {c.title}: {c.description}')
+1
View File
@@ -0,0 +1 @@
UPDATE agents SET mfa_enabled = true, mfa_secret = 'JBSWY3DPEHPK3PXP' WHERE user_id = 'sxn'