Praqma / staci

Containerizing the Atlassian tools stack. Jira, Confluence, Bamboo and a MySQL database.
MIT License
12 stars 5 forks source link

During install, wait for MySQL to start, instead of sleep #38

Closed martinmosegaard closed 8 years ago

martinmosegaard commented 8 years ago

This issue tracks a TODO in staciFunctions.f / installStaci in this code:

  if [ ! -z $start_mysql ];then
    # TODO: Need to wait for MySQL to start, before continuing, instead of sleep
    sleep 20
hoeghh commented 8 years ago

Inspiration from a mongodb container:

#!/bin/bash

attempt=0
while [ $attempt -le 59 ]; do
    attempt=$(( $attempt + 1 ))
    echo "Waiting for server to be up (attempt: $attempt)..."
    result=$(docker logs mongo)
    if grep -q 'waiting for connections on port 27017' <<< $result ; then
      echo "Mongodb is up!"
      break
    fi
    sleep 2
done
hoeghh commented 8 years ago

Now, output as this :

Installing using property files, please wait....
 - Using /home/hoeghh/atlassian for persistence
 - Using /home/hoeghh/atlassian/backup for backup

 - Building images
  # Building base image, please wait...
    - Building base image.
  # Building Atlassian, please wait...
   - Building Jira image
   - Building MySQL image
 - Generating docker-compose.yml - OK
 - Starting containers, using docker-compose
 - Container mysql is active, waiting to be ready
 - MySQL is up!
 - Setting up MySQL for Jira

 - Database Type : MySQL
 - Hostname : atlassiandb
 - Port : 3306
 - Database : jiradb
 - Username : jiradbuser
 - Password : jirapass

Install complete
Open /home/hoeghh/Development/staci/SystemInfo.html in a browser to continue using the tool stack