Skip to content

Commit

Permalink
feat: docker-compose healthz check (#1680)
Browse files Browse the repository at this point in the history
Co-authored-by: 胡浩 <huhao@anesec.cn>
  • Loading branch information
hoorayman and 胡浩 committed Mar 20, 2024
1 parent d4b9c2c commit ebefb0e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
16 changes: 14 additions & 2 deletions deploy/docker-compose/docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ services:
ports:
- '8888:8888'
depends_on:
- mysql
- redis
mysql:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ../../server:/server
working_dir: /server # 如果docker 设置了workdir 则此处不需要设置
Expand All @@ -67,6 +69,11 @@ services:
MYSQL_DATABASE: 'qmPlus' # 初始化启动时要创建的数据库的名称
MYSQL_USER: 'gva'
MYSQL_PASSWORD: 'Aa@6447985'
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "gva", "-pAa@6447985"]
interval: 10s
timeout: 5s
retries: 3
volumes:
- mysql:/var/lib/mysql
networks:
Expand All @@ -80,6 +87,11 @@ services:
restart: always
ports:
- '16379:6379'
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG || exit 1"]
interval: 10s
timeout: 5s
retries: 3
volumes:
- redis:/data
networks:
Expand Down
16 changes: 14 additions & 2 deletions deploy/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ services:
ports:
- '8888:8888'
depends_on:
- mysql
- redis
mysql:
condition: service_healthy
redis:
condition: service_healthy
links:
- mysql
- redis
Expand All @@ -59,6 +61,11 @@ services:
MYSQL_DATABASE: 'qmPlus' # 初始化启动时要创建的数据库的名称
MYSQL_USER: 'gva'
MYSQL_PASSWORD: 'Aa@6447985'
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "gva", "-pAa@6447985"]
interval: 10s
timeout: 5s
retries: 3
volumes:
- mysql:/var/lib/mysql
networks:
Expand All @@ -71,6 +78,11 @@ services:
restart: always
ports:
- '16379:6379'
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG || exit 1"]
interval: 10s
timeout: 5s
retries: 3
volumes:
- redis:/data
networks:
Expand Down

0 comments on commit ebefb0e

Please sign in to comment.