From 5a08ea24b4acea0ece6fd4ad947c2d0bc5cf8a39 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Sat, 2 Feb 2019 04:13:52 +0900 Subject: [PATCH] Add or fix comments --- .travis.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index df60875d..1fb7cf93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ git: env: global: - MEDIAWIKI_BRANCH=REL1_31 + # Maximum iteration limit for loop - LOOP_LIMIT=300 cache: @@ -32,31 +33,42 @@ jobs: - composer test . - name: docker before_script: + # Setup files for database and memcached - git clone https://github.com/femiwiki/database.git ~/swarm --depth=1 - sudo mkdir -p /srv/mysql/ + # Prepare configuration files - cp configs/env.example configs/env - cp configs/secret.php.example configs/secret.php + # Tweak LocalSettings.php for debugging - echo -en "\n\nwfRunDebugMode( 'localhost' );\n" >> configs/LocalSettings.php - echo -en '\n\nrequire_once "$IP/includes/DevelopmentSettings.php";\n' >> configs/LocalSettings.php + # Initialize docker swarm - docker swarm init - # Setup database + # Start up database - docker stack deploy -c ~/swarm/database.yml database + # We need root password of the database, so wait for the generation - | printf 'Waiting for database_mysql service...'; + # Set counter to check endless loop COUNTER=0; while [ -z $(docker service logs database_mysql 2>&1 | grep -oP 'GENERATED ROOT PASSWORD: \K.+') ]; do + # retry every 1 second. sleep 1; + # Append dots to the previous message if process is delayed. printf '.'; + # Terminate Travis-ci if loop exceeds limit (( COUNTER++ )); if [ $COUNTER -gt $LOOP_LIMIT ]; then printf '\n'; echo 'Falied to start database_mysql service'; + # Print logs for debugging docker service logs database_mysql; travis_terminate 1; fi done; printf '\n' - # Setup memcached + # Start up memcached - docker stack deploy -c ~/swarm/memcached.yml memcached + # Configure mediawiki - HOST_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') - MYSQL_USER=root - "MYSQL_PW=$(docker service logs database_mysql 2>&1 | grep -Po 'GENERATED ROOT PASSWORD: \\K.+')" @@ -73,7 +85,9 @@ jobs: # We don't have a health check yet, so wait a moment for starting process is end... - sleep 60 - docker service logs mediawiki_fastcgi + # Check if container is shoutdown - test -z "$(docker service ps -qf "desired-state=Shutdown" mediawiki_fastcgi)" + # Access localhost until success - | printf 'Waiting for http...' COUNTER=0;