This repository has been archived by the owner on Feb 15, 2022. It is now read-only.
forked from openstack-archive/poppy
-
Notifications
You must be signed in to change notification settings - Fork 8
/
run_poppy.sh
executable file
·92 lines (72 loc) · 1.69 KB
/
run_poppy.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
DAEMONIZED=false
WORKERS=6
for i in "$@"
do
case $i in
-d|--daemonized)
DAEMONIZED=true
shift # past argument=value
;;
-w=*|--workers=*)
WORKERS="${i#*=}"
shift # past argument=value
;;
-?|--help)
echo "USAGE: ./run_poppy.sh -d -w=10"
echo "-d | --daemonized : run in daemonized mode"
echo "-w | --workers : the number of poppy-worker processes to spawn (defaults to 6)"
exit
shift
;;
*)
echo "Invalid Options"
echo "Run ./run_poppy.sh --help for valid parameters."
exit
# unknown option
;;
esac
done
pip install docker-compose
# remove existing containers
docker kill compose_cassandra_1
docker kill compose_zookeeper_1
docker rm compose_cassandra_1
docker rm compose_zookeeper_1
# start new containers
docker-compose -f docker/compose/dependencies.yml up -d
is_cassandra_ready() {
nc -z dockerhost 9042
}
is_zookeeper_ready() {
nc -z dockerhost 2181
}
# wait until cassandra is ready
while ! is_cassandra_ready -eq 1
do
echo "still trying to connect to cassandra"
sleep 1
done
echo "connected successfully to cassandra"
# wait until zookeeper is ready
while ! is_zookeeper_ready -eq 1
do
echo "still trying to connect to zookeeper"
sleep 1
done
echo "connected successfully to zookeeper"
# start the poppy-workers
COUNTER=0
while [ $COUNTER -lt $WORKERS ]; do
exec poppy-worker > /dev/null 2>&1 &
echo "poppy-worker spawned."
let COUNTER=COUNTER+1
done
# start the poppy-server
if $DAEMONIZED; then
exec poppy-server > /dev/null 2>&1 &
echo "poppy-server spawned."
else
exec poppy-server
fi
echo "Poppy Server and Workers Started"