Commit af90953d authored by Abhishek's avatar Abhishek
Browse files

wait added in script

parent 8ed298af
Pipeline #11804 passed with stage
in 8 minutes and 29 seconds
...@@ -37,25 +37,23 @@ echo " -> Using Moodle URL: $MOODLE_URL" ...@@ -37,25 +37,23 @@ echo " -> Using Moodle URL: $MOODLE_URL"
echo " -> Using Backend URL: $BACKEND_URL" echo " -> Using Backend URL: $BACKEND_URL"
# --- THIS IS THE FIX --- # --- THIS IS THE FIX ---
# We use an 'until' loop. This will continue to run as long as the command # We now wait for the Moodle web application itself to be fully responsive.
# fails (returns a non-zero exit code). It will only stop when the mysql # We repeatedly curl the login page until we get a 200 OK status code.
# command is 100% successful, which guarantees the database is fully installed. # This is the most reliable way to know the site is ready.
echo " -> Waiting for Moodle first-time installation to complete..." echo " -> Waiting for Moodle web server to be ready..."
timeout=300 # 5 minute timeout timeout=300 # 5 minute timeout
until docker exec "$DB_CONTAINER_NAME" mysql -u root -p"$DB_ROOT_PASSWORD" "$DB_NAME" -e "SELECT 1 FROM mdl_config WHERE name = 'version' LIMIT 1;" > /dev/null 2>&1 until curl --output /dev/null --silent --head --fail "$MOODLE_URL/login/index.php"; do
do
timeout=$((timeout - 5)) timeout=$((timeout - 5))
if [ $timeout -le 0 ]; then if [ $timeout -le 0 ]; then
echo "❌ ERROR: Moodle installation timed out after 5 minutes." echo "❌ ERROR: Moodle web server did not become ready after 5 minutes."
echo "--- MOODLE CONTAINER LOGS ---" echo "--- MOODLE CONTAINER LOGS ---"
docker logs "$MOODLE_CONTAINER" docker logs "$MOODLE_CONTAINER"
exit 1 exit 1
fi fi
echo " -> Database not yet ready, waiting 5 more seconds..." echo " -> Moodle web server not yet ready, waiting 5 more seconds..."
sleep 5 sleep 5
done done
echo "✅ Moodle installation complete (database version found)." echo "✅ Moodle web server is responsive."
# --- Pre-flight Checks & Plugin Install (Step 1) --- # --- Pre-flight Checks & Plugin Install (Step 1) ---
if ! docker ps --format '{{.Names}}' | grep -qw "$MOODLE_CONTAINER"; then echo "❌ Moodle container not running." && exit 1; fi if ! docker ps --format '{{.Names}}' | grep -qw "$MOODLE_CONTAINER"; then echo "❌ Moodle container not running." && exit 1; fi
if [ ! -f "$PLUGIN_ZIP_NAME" ]; then echo "❌ Plugin ZIP file not found." && exit 1; fi if [ ! -f "$PLUGIN_ZIP_NAME" ]; then echo "❌ Plugin ZIP file not found." && exit 1; fi
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment