feat(docker): 测试环境 compose 添加自动迁移 + healthcheck
- api 服务启动时自动执行 alembic upgrade head,再启动 uvicorn - api 添加 healthcheck(/health 端点检查) - scheduler 添加 healthcheck(导入检查)
This commit is contained in:
@@ -54,9 +54,17 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
command: >
|
||||
sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000"
|
||||
networks:
|
||||
- meijiaka-zy
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:8000/health')\""]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
scheduler:
|
||||
build:
|
||||
@@ -73,6 +81,12 @@ services:
|
||||
networks:
|
||||
- meijiaka-zy
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "python -c \"import asyncio; from app.scheduler.engine import AsyncEngine; print('scheduler ok')\""]
|
||||
interval: 60s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
|
||||
networks:
|
||||
meijiaka-zy:
|
||||
|
||||
Reference in New Issue
Block a user