fix: frontend depends app health

This commit is contained in:
wizardchen
2025-09-11 14:15:58 +08:00
committed by lyingbug
parent bff0e742fa
commit 78088057fb
4 changed files with 20 additions and 2 deletions
+1 -1
View File
@@ -168,7 +168,7 @@ deps:
# Build for production # Build for production
build-prod: build-prod:
GOOS=linux go build -a -installsuffix cgo -ldflags="-w -s" -o $(BINARY_NAME) $(MAIN_PATH) GOOS=linux go build -installsuffix cgo -ldflags="-w -s" -o $(BINARY_NAME) $(MAIN_PATH)
clean-db: clean-db:
@echo "Cleaning database..." @echo "Cleaning database..."
+8 -1
View File
@@ -7,6 +7,12 @@ services:
volumes: volumes:
- data-files:/data/files - data-files:/data/files
- ./config/config.yaml:/app/config/config.yaml - ./config/config.yaml:/app/config/config.yaml
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
environment: environment:
- COS_SECRET_ID=${COS_SECRET_ID} - COS_SECRET_ID=${COS_SECRET_ID}
- COS_SECRET_KEY=${COS_SECRET_KEY} - COS_SECRET_KEY=${COS_SECRET_KEY}
@@ -102,7 +108,8 @@ services:
ports: ports:
- "${FRONTEND_PORT:-80}:80" - "${FRONTEND_PORT:-80}:80"
depends_on: depends_on:
- app app:
condition: service_healthy
networks: networks:
- WeKnora-network - WeKnora-network
restart: unless-stopped restart: unless-stopped
+10
View File
@@ -3,6 +3,10 @@ server {
server_name localhost; server_name localhost;
client_max_body_size 50M; client_max_body_size 50M;
# 错误日志配置
error_log /var/log/nginx/error.log warn;
access_log /var/log/nginx/access.log;
# 前端静态文件 # 前端静态文件
location / { location / {
root /usr/share/nginx/html; root /usr/share/nginx/html;
@@ -18,6 +22,12 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
# 连接和重试配置
proxy_connect_timeout 30s; # 连接超时时间
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_next_upstream_tries 3; # 重试次数
proxy_next_upstream_timeout 30s; # 重试超时时间
# SSE 相关配置 # SSE 相关配置
proxy_http_version 1.1; # 使用 HTTP/1.1 proxy_http_version 1.1; # 使用 HTTP/1.1
proxy_set_header Connection ""; # 禁用 Connection: close,保持连接打开 proxy_set_header Connection ""; # 禁用 Connection: close,保持连接打开
+1
View File
@@ -19,6 +19,7 @@ var noAuthAPI = map[string][]string{
"/api/v1/test-data": {"GET"}, "/api/v1/test-data": {"GET"},
"/api/v1/tenants": {"POST"}, "/api/v1/tenants": {"POST"},
"/api/v1/initialization/*": {"GET", "POST"}, "/api/v1/initialization/*": {"GET", "POST"},
"/health": {"GET"},
} }
// 检查请求是否在无需认证的API列表中 // 检查请求是否在无需认证的API列表中