-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
68 lines (58 loc) · 1.12 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
function mongo_ready(){
python << END
import sys
import pymongo
try:
client = pymongo.MongoClient('mongodb://database:27017', serverSelectionTimeoutMS=1000)
client.server_info()
except:
sys.exit(-1)
sys.exit(0)
END
}
function frog_ready(){
python << END
import sys
from pynlpl.clients.frogclient import FrogClient
try:
frogclient = FrogClient('frog', 12345, returnall=True)
except:
sys.exit(-1)
sys.exit(0)
END
}
function redis_ready(){
python << END
import sys
from redis import Redis
try:
Redis(host='redis', port=6379).ping()
except:
sys.exit(-1)
sys.exit(0)
END
}
until mongo_ready; do
>&2 echo "Waiting for MongoDB to come online"
sleep 1
done &
mongo_waiter_pid=$!
until frog_ready; do
>&2 echo "Waiting for FROG service to come online"
sleep 1
done &
frog_waiter_pid=$!
until redis_ready; do
>&2 echo "Waiting for Redis service to come online"
sleep 1
done &
redis_waiter_pid=$!
wait ${mongo_waiter_pid}
wait ${frog_waiter_pid}
wait ${redis_waiter_pid}
>&2 echo "FROG & Redis & MongoDB are up - continuing..."
exec "$@"