]> git.parisson.com Git - docker-django-scripts.git/commitdiff
Fix wait for restoring DB
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 28 Mar 2018 14:31:48 +0000 (16:31 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 28 Mar 2018 14:31:48 +0000 (16:31 +0200)
dev/local/restore_db.sh
dev/restore_db.sh
misc/wait.sh

index 27915f0985682e1406c1c255e4c0c798bfcb3618..b48c0577dcaddfeabe009acc8e9bc9ae9f968445 100755 (executable)
@@ -1,11 +1,8 @@
 #!/bin/bash
 
-# import dump functions of the database (postgres or mysql)
-# export POSTGRES="$(dpkg --get-selections  | grep postgres 2>&1)"
-# export MYSQL="$(dpkg --get-selections  | grep mysql 2>&1)"
+set -e
 
-# wait for db
-# /srv/bin/misc/wait.sh
+echo "Restoring..."
 
 # import database functions of type
 if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then
index 53b9bc4f770e9c68094f10b308f8e1c391d55daf..5916ad58383a0a648ff92d252c6fc2a26ebff581 100755 (executable)
@@ -1,3 +1,5 @@
 #!/bin/sh
 
-docker-compose run db /srv/bin/dev/local/restore_db.sh
+docker-compose up -d db
+docker-compose run db bash -c "/srv/bin/misc/wait.sh; /srv/bin/dev/local/restore_db.sh; /srv/bin/dev/local/restore_db.sh"
+docker-compose stop db
index 202c4d133d904b8b84c40cdddf5871ccf1990566..26a309f425b35fd0b981f1750b4b0b315d45126c 100755 (executable)
@@ -1,13 +1,16 @@
-#!/bin/sh
+#!/bin/bash
 
 set -e
 
-host=$(env | grep _TCP_ADDR | cut -d = -f 2)
-port=$(env | grep _TCP_PORT | cut -d = -f 2)
+apt update
+apt install -y netcat
 
-echo -n "waiting for TCP connection to $host:$port..."
+HOST=db
+PORT=5432
 
-while ! nc -w 1 $host $port 2>/dev/null
+echo -n "waiting for TCP connection to $HOST:$PORT..."
+
+while ! nc -w 1 $HOST $PORT 2>/dev/null
 do
   echo -n .
   sleep 1