-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·56 lines (47 loc) · 1.09 KB
/
docker-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
#!/bin/bash
set -e
COMMANDS="debug help logtail show stop adduser fg kill quit run wait console foreground logreopen reload shell status"
START="start restart zeoserver"
CMD="bin/instance"
python /docker-initialize.py
if [ -e "custom.cfg" ]; then
if [ ! -e "bin/develop" ]; then
buildout -c custom.cfg
python /docker-initialize.py
fi
fi
if [[ "$1" == "zeo"* ]]; then
CMD="bin/$1"
fi
if [ -z "$HEALTH_CHECK_TIMEOUT" ]; then
HEALTH_CHECK_TIMEOUT=1
fi
if [ -z "$HEALTH_CHECK_INTERVAL" ]; then
HEALTH_CHECK_INTERVAL=1
fi
if [[ $START == *"$1"* ]]; then
_stop() {
$CMD stop
kill -TERM $child 2>/dev/null
}
trap _stop SIGTERM SIGINT
$CMD start
$CMD logtail &
child=$!
pid=`$CMD status | sed 's/[^0-9]*//g'`
if [ ! -z "$pid" ]; then
echo "Application running on pid=$pid"
sleep "$HEALTH_CHECK_TIMEOUT"
while kill -0 "$pid" 2> /dev/null; do
sleep "$HEALTH_CHECK_INTERVAL"
done
else
echo "Application didn't start normally. Shutting down!"
_stop
fi
else
if [[ $COMMANDS == *"$1"* ]]; then
exec bin/instance "$@"
fi
exec "$@"
fi