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

View File

@@ -168,7 +168,7 @@ deps:
# Build for production
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:
@echo "Cleaning database..."

View File

@@ -7,6 +7,12 @@ services:
volumes:
- data-files:/data/files
- ./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:
- COS_SECRET_ID=${COS_SECRET_ID}
- COS_SECRET_KEY=${COS_SECRET_KEY}
@@ -102,7 +108,8 @@ services:
ports:
- "${FRONTEND_PORT:-80}:80"
depends_on:
- app
app:
condition: service_healthy
networks:
- WeKnora-network
restart: unless-stopped

View File

@@ -2,6 +2,10 @@ server {
listen 80;
server_name localhost;
client_max_body_size 50M;
# 错误日志配置
error_log /var/log/nginx/error.log warn;
access_log /var/log/nginx/access.log;
# 前端静态文件
location / {
@@ -18,6 +22,12 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
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 相关配置
proxy_http_version 1.1; # 使用 HTTP/1.1
proxy_set_header Connection ""; # 禁用 Connection: close保持连接打开

View File

@@ -19,6 +19,7 @@ var noAuthAPI = map[string][]string{
"/api/v1/test-data": {"GET"},
"/api/v1/tenants": {"POST"},
"/api/v1/initialization/*": {"GET", "POST"},
"/health": {"GET"},
}
// 检查请求是否在无需认证的API列表中