From d0ea0535e2963f4ac9ffbd74ef2ecde0d8bf9f73 Mon Sep 17 00:00:00 2001 From: anthorob Date: Sun, 18 Oct 2026 01:53:10 -0400 Subject: [PATCH] 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. --- docker-compose.yml | 12 ++++++++++-- startup.sh | 3 --- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a1b8c1e..d583704 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,12 @@ services: - MYSQL_DATABASE=${MYSQL_DATABASE:-netneutrality} - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-password} - MARIADB_AUTO_UPGRADE=1 + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 5s + timeout: 5s + retries: 20 + start_period: 30s netneutrality-bot: image: gitea.bobert.me/anthorob/netneutrality:${NETNEUTRALITY_TAG:-latest} @@ -22,8 +28,10 @@ services: networks: - netneutrality depends_on: - - netneutrality-db - - lavalink + netneutrality-db: + condition: service_healthy + lavalink: + condition: service_started volumes: - ./logs:/app/logs environment: diff --git a/startup.sh b/startup.sh index d06214a..50d3174 100644 --- a/startup.sh +++ b/startup.sh @@ -26,9 +26,6 @@ if [ ! -f /usr/bin/nc ]; then exit 1 fi -echo "Waiting 10 seconds for database to start.." -sleep 10 - echo "Checking if MySQL / MariaDB is started.." if /usr/bin/nc -z $MYSQL_HOST $MYSQL_PORT; then echo "Database OK. Starting bot..";