wso2 / pivotal-cf-apim

Apache License 2.0
35 stars 13 forks source link

Fix logic that waits for mysql service to start #21

Closed imesh closed 6 years ago

imesh commented 6 years ago

Purpose

This pull request fixes the logic which waits for MySQL service to start. The existing logic waits for the mysql socket to be activated however inside the mysql container the mysql service get started twice due to it's initialization logic. Once the mysql container is started the mysql service get initiated, then the mysql initialization process runs, afterwards the mysql service get stopped. Thereafter, the mysql service get started again. For this reason the existing check get passed before mysql service is ready to accept database connections.

This fix checks for the server activation log count to be two to make sure that mysql service is ready to accept connections:

    echo -e "---> Waiting for MySQL service to start at ${docker_host_ip}:3306..."
    while [ $(docker logs mysql-5.7 2>&1 | grep "mysqld: ready for connections" | wc -l) -ne "2" ]; do 
        printf '.'
        sleep 1
    done