Improve service startup reliability and DB readiness checks

Adds healthcheck to the database service in docker-compose and ensures the web service waits for the database to be healthy before starting. Updates script.sh to wait for the database to be ready before proceeding. Enhances the Cypress workflow to retry DXCC population for improved test reliability.
这个提交包含在:
Peter Goodhall 2025-07-17 17:13:12 +01:00
父节点 ca5df78114
当前提交 bd1a92d660
共有 3 个文件被更改,包括 27 次插入2 次删除

查看文件

@ -59,7 +59,16 @@ jobs:
done
- name: Populate dxcc_entities table
run: curl "http://localhost/index.php/update/dxcc"
run: |
for i in `seq 1 10`; do
if curl -f "http://localhost/index.php/update/dxcc"; then
echo "DXCC entities populated successfully"
break
else
echo "Failed to populate DXCC entities, retrying in 10 seconds... (attempt $i/10)"
sleep 10
fi
done
- name: Run Cypress tests
run: npx cypress run

查看文件

@ -14,7 +14,8 @@ services:
- ./:/var/www/html:rw
command: ["./script.sh"]
depends_on:
- db
db:
condition: service_healthy
networks:
- mynet
@ -28,5 +29,12 @@ services:
- db_data:/var/lib/mysql
networks:
- mynet
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 20s
retries: 10
interval: 10s
start_period: 30s
volumes:
db_data: {}

查看文件

@ -79,6 +79,14 @@ rm -rf /install
echo "Replacement complete."
# Wait for database to be ready
echo "Waiting for database to be ready..."
until mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "SELECT 1" > /dev/null 2>&1; do
echo "Database is not ready yet. Waiting 5 seconds..."
sleep 5
done
echo "Database is ready!"
# Set Permissions
chown -R root:www-data /var/www/html/application/config/
chown -R root:www-data /var/www/html/application/logs/