-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.sh
More file actions
executable file
·28 lines (23 loc) · 894 Bytes
/
startup.sh
File metadata and controls
executable file
·28 lines (23 loc) · 894 Bytes
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
#!/usr/bin/env bash
SERVER=elastic:9200
WAIT_LOOPS=10
WAIT_SLEEP=5
WAIT_COMMAND='curl --write-out %{http_code} --silent --output /dev/null http://elastic:9200/_cat/health?h=st'
START_COMMAND='/usr/local/bin/gunicorn -k gevent --reload --workers 10 --worker-connections 10 --access-logfile=- --pythonpath /app -b :5000 server:app'
BASE=$(cd `dirname $0` && echo $PWD)
# wait for Elastic?
if [ "`grep -v '#' $BASE/config.yml | grep 'index:'`" != "" -a "`grep -v '#' $BASE/config.yml | egrep 'type:[ \t]+elastic'`" != "" ] ; then
# wait for Elastic
echo "Waiting for elastic ..."
i=0
while [ "`$WAIT_COMMAND`" != "200" ]; do
i=`expr $i + 1`
if [ $i -ge $WAIT_LOOPS ]; then
echo "$(date) - still not ready, giving up"
exit 1
fi
echo "$(date) - $i waiting to be ready"
sleep $WAIT_SLEEP
done
fi
$START_COMMAND