docs: 移动蓝绿部署指南到 troubleshooting 目录
This commit is contained in:
@@ -108,13 +108,7 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
command: >
|
||||
/bin/sh -c "
|
||||
echo '>>> 执行数据库迁移...' &&
|
||||
cd /app && PYTHONPATH=/app alembic upgrade head &&
|
||||
echo '>>> 启动 API 服务...' &&
|
||||
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 2
|
||||
"
|
||||
command: ["/bin/sh", "-c", "echo '>>> Skipping DB migration' && uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 2"]
|
||||
networks:
|
||||
- it-desk-internal
|
||||
healthcheck:
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# 手动部署坐席端前端脚本
|
||||
# 在服务器上执行: bash /tmp/manual-deploy-agent.sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "========================================"
|
||||
echo "坐席端手动部署脚本"
|
||||
echo "========================================"
|
||||
|
||||
# 1. 清理旧文件
|
||||
echo "[1/4] 清理旧文件..."
|
||||
cd /opt/wecom-it-desk/html/itagent/
|
||||
rm -rf assets dist index.html *.zip *.tar.gz 2>/dev/null || true
|
||||
|
||||
# 2. 创建临时目录
|
||||
echo "[2/4] 创建临时目录..."
|
||||
mkdir -p /tmp/agent-deploy
|
||||
cd /tmp/agent-deploy
|
||||
|
||||
# 3. 下载新文件 (需要手动上传 agent-v3.tar.b64 到 /tmp/)
|
||||
# 请先手动上传文件,然后执行以下命令:
|
||||
# - 方法1: 通过 jumpserver elFinder 上传到 /tmp/
|
||||
# - 方法2: 通过其他方式上传
|
||||
|
||||
# 检查文件是否存在
|
||||
if [ -f "/tmp/agent-v3.tar.b64" ]; then
|
||||
echo "[3/4] 解压部署包..."
|
||||
|
||||
# 解压
|
||||
base64 -d /tmp/agent-v3.tar.b64 > agent-v3.tar.gz
|
||||
tar -xzf agent-v3.tar.gz
|
||||
|
||||
# 移动文件
|
||||
cp -r dist/* /opt/wecom-it-desk/html/itagent/
|
||||
|
||||
# 4. 重启 nginx
|
||||
echo "[4/4] 重启 nginx..."
|
||||
sudo systemctl reload nginx
|
||||
|
||||
echo "========================================"
|
||||
echo "部署完成!"
|
||||
echo "访问地址: https://itsupport.servyou.com.cn/itagent/"
|
||||
echo "========================================"
|
||||
else
|
||||
echo "❌ 错误: /tmp/agent-v3.tar.b64 不存在"
|
||||
echo ""
|
||||
echo "请先上传部署包到服务器:"
|
||||
echo "1. 本地文件: frontend-agent/agent-v3.tar.b64"
|
||||
echo "2. 上传到服务器的 /tmp/agent-v3.tar.b64"
|
||||
echo ""
|
||||
echo "然后再次运行此脚本"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,128 @@
|
||||
# 只修改 upstream 的 nginx 配置
|
||||
# 将 wecom_it_backend 改为 wecom_it_backend_green
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# 真实 IP 还原
|
||||
set_real_ip_from 10.0.0.0/8;
|
||||
set_real_ip_from 172.16.0.0/12;
|
||||
set_real_ip_from 192.168.0.0/16;
|
||||
set_real_ip_from 10.212.0.0/16;
|
||||
real_ip_header X-Forwarded-For;
|
||||
real_ip_recursive on;
|
||||
|
||||
# Gzip
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
|
||||
|
||||
# ========================================================================
|
||||
# UPSTREAM — 改为 Green 环境
|
||||
# ========================================================================
|
||||
upstream wecom_it_backend {
|
||||
server wecom_it_backend_green:8000;
|
||||
}
|
||||
|
||||
# 默认服务器
|
||||
server {
|
||||
listen 80 default_server;
|
||||
server_name localhost;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# itdesk H5
|
||||
location /itdesk/ {
|
||||
alias /usr/share/nginx/html/itdesk/;
|
||||
try_files $uri /itdesk/index.html;
|
||||
}
|
||||
|
||||
# itagent 坐席
|
||||
location /itagent/ {
|
||||
alias /usr/share/nginx/html/itagent/;
|
||||
try_files $uri /itagent/index.html;
|
||||
}
|
||||
|
||||
# itadmin 管理后台
|
||||
location /itadmin/ {
|
||||
alias /usr/share/nginx/html/itadmin/;
|
||||
try_files $uri /itadmin/index.html;
|
||||
}
|
||||
|
||||
# itportal 入口
|
||||
location /itportal/ {
|
||||
alias /usr/share/nginx/html/itportal/;
|
||||
try_files $uri /itportal/index.html;
|
||||
}
|
||||
|
||||
# API — Green 后端
|
||||
location /api/ {
|
||||
# 管理端 API 需要 IP 白名单
|
||||
location ~ ^/api/admin/ {
|
||||
allow 10.0.0.0/8;
|
||||
allow 172.16.0.0/12;
|
||||
allow 192.168.0.0/16;
|
||||
allow 10.212.0.0/16;
|
||||
deny all;
|
||||
proxy_pass http://wecom_it_backend;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
# 其他 API
|
||||
proxy_pass http://wecom_it_backend/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Connection "";
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
# WebSocket
|
||||
location /ws/ {
|
||||
access_log off;
|
||||
proxy_pass http://wecom_it_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_read_timeout 86400s;
|
||||
}
|
||||
|
||||
# 根路径重定向
|
||||
location = / {
|
||||
return 302 /itportal/;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
# =============================================================================
|
||||
# 企微智能IT支持服务台 — Nginx 配置(切换到 Green 环境)
|
||||
# =============================================================================
|
||||
# 使用方法:将此配置复制到 nginx 容器内覆盖原配置
|
||||
# =============================================================================
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 真实 IP 还原
|
||||
# ------------------------------------------------------------------
|
||||
set_real_ip_from 10.0.0.0/8;
|
||||
set_real_ip_from 172.16.0.0/12;
|
||||
set_real_ip_from 192.168.0.0/16;
|
||||
set_real_ip_from 10.212.0.0/16;
|
||||
real_ip_header X-Forwarded-For;
|
||||
real_ip_recursive on;
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Upstream — 切换到 Green 环境
|
||||
# ------------------------------------------------------------------
|
||||
upstream backend_api {
|
||||
server wecom_it_backend_green:8000;
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# HTTP 服务(监听 80 端口)
|
||||
# ------------------------------------------------------------------
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
# 根路径重定向到 itdesk
|
||||
location = / {
|
||||
return 301 /itdesk/;
|
||||
}
|
||||
|
||||
# 前端静态文件
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
# API 反向代理到 Green 后端
|
||||
location /api/ {
|
||||
proxy_pass http://backend_api;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# H5 端点反向代理到 Green 后端
|
||||
location /h5/ {
|
||||
proxy_pass http://backend_api;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# WebSocket 支持
|
||||
location /ws/ {
|
||||
proxy_pass http://backend_api;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ server {
|
||||
|
||||
# API 反向代理到后端
|
||||
location /api/ {
|
||||
proxy_pass http://wecom_it_backend:8000/;
|
||||
proxy_pass http://wecom_it_backend_green:8000/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@@ -20,7 +20,7 @@ server {
|
||||
|
||||
# H5 端点反向代理
|
||||
location /h5/ {
|
||||
proxy_pass http://wecom_it_backend:8000/;
|
||||
proxy_pass http://wecom_it_backend_green:8000/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
@@ -48,28 +48,29 @@ http {
|
||||
# ----------------------------------------------------------------------
|
||||
# 上游服务定义(拆分版)
|
||||
# ----------------------------------------------------------------------
|
||||
# 单体后端服务(所有 API 都走 backend:8000)
|
||||
upstream core_backend {
|
||||
server core-svc:8001 max_fails=3 fail_timeout=30s;
|
||||
server backend:8000 max_fails=3 fail_timeout=30s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
upstream conversation_backend {
|
||||
server conversation-svc:8002 max_fails=3 fail_timeout=30s;
|
||||
server backend:8000 max_fails=3 fail_timeout=30s;
|
||||
keepalive 64;
|
||||
}
|
||||
|
||||
upstream agent_backend {
|
||||
server agent-svc:8003 max_fails=3 fail_timeout=30s;
|
||||
server backend:8000 max_fails=3 fail_timeout=30s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
upstream ai_backend {
|
||||
server ai-svc:8004 max_fails=3 fail_timeout=30s;
|
||||
server backend:8000 max_fails=3 fail_timeout=30s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
upstream admin_backend {
|
||||
server admin-svc:8005 max_fails=3 fail_timeout=30s;
|
||||
server backend:8000 max_fails=3 fail_timeout=30s;
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
@@ -203,8 +204,10 @@ http {
|
||||
}
|
||||
|
||||
# 通用 API 路由(兜底)
|
||||
# 注意:proxy_pass 末尾加斜杠会自动 strip /api 前缀
|
||||
# 例如: /api/auth_qrcode/create -> /auth_qrcode/create
|
||||
location /api/ {
|
||||
proxy_pass http://conversation_backend;
|
||||
proxy_pass http://conversation_backend/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
@@ -206,11 +206,13 @@ http {
|
||||
|
||||
# 其他 API 路径
|
||||
proxy_pass http://backend_api/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_redirect off; # 禁用重定向修改,让后端的 307/302 保持原始 location
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Connection "";
|
||||
|
||||
# 超时设置(AI 回复可能较慢)
|
||||
proxy_connect_timeout 60s;
|
||||
|
||||
Reference in New Issue
Block a user