Add health checks and dependency conditions in docker-compose.yml

Introduced health checks for `netneutrality-db` to ensure proper readiness before dependent services start. Replaced static sleep in `startup.sh` with dynamic database availability checks, improving startup reliability and reducing downtime risks.
This commit is contained in:
anthorob committed 2026-10-18 01:53:10 -04:00
1 parent 78d6ade17a
commit d0ea0535e2
2 files changed
+10 -5

No files matched your search

+10 -2
View File
@@ -13,6 +13,12 @@ services:
- MYSQL_DATABASE=${MYSQL_DATABASE:-netneutrality} - MYSQL_DATABASE=${MYSQL_DATABASE:-netneutrality}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-password} - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-password}
- MARIADB_AUTO_UPGRADE=1 - MARIADB_AUTO_UPGRADE=1
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 5s
timeout: 5s
retries: 20
start_period: 30s
netneutrality-bot: netneutrality-bot:
image: gitea.bobert.me/anthorob/netneutrality:${NETNEUTRALITY_TAG:-latest} image: gitea.bobert.me/anthorob/netneutrality:${NETNEUTRALITY_TAG:-latest}
@@ -22,8 +28,10 @@ services:
networks: networks:
- netneutrality - netneutrality
depends_on: depends_on:
- netneutrality-db netneutrality-db:
- lavalink condition: service_healthy
lavalink:
condition: service_started
volumes: volumes:
- ./logs:/app/logs - ./logs:/app/logs
environment: environment:
-3
View File
@@ -26,9 +26,6 @@ if [ ! -f /usr/bin/nc ]; then
exit 1 exit 1
fi fi
echo "Waiting 10 seconds for database to start.."
sleep 10
echo "Checking if MySQL / MariaDB is started.." echo "Checking if MySQL / MariaDB is started.."
if /usr/bin/nc -z $MYSQL_HOST $MYSQL_PORT; then if /usr/bin/nc -z $MYSQL_HOST $MYSQL_PORT; then
echo "Database OK. Starting bot.."; echo "Database OK. Starting bot..";