-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·94 lines (87 loc) · 2.24 KB
/
entrypoint.sh
File metadata and controls
executable file
·94 lines (87 loc) · 2.24 KB
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
93
94
#!/bin/bash
set -e
ENVIRONMENT=${ENVIRONMENT:-production}
echo "ENVIRONMENT=${ENVIRONMENT}"
help() {
echo "Docker entrypoint script."
echo ""
echo "Usage:"
echo ""
echo "manage -- run CLI to management command"
echo "shell -- run management shell"
echo ""
echo "run_periodic -- start Huey periodic jobs runner with optional code reloading"
echo "run_worker -- start a Huey workers with optional code reloading"
echo "run_server -- start Flask / gunicorn server"
echo ""
echo "For live code reloading set ENVIRONMENT=development"
echo ""
echo "Example:"
echo ""
echo "docker <CONTAINER> exec manage database create-tables"
echo "docker -it <CONTAINER> exec shell"
echo ""
}
run_worker() {
echo "Starting Huey worker (${ENVIRONMENT}) ..."
if [ ${ENVIRONMENT} = "development" ]; then
exec watchmedo auto-restart -d=./redash/ -d=./dingolytics/ -p=*.py -R -- \
python -m dingolytics.worker default
else
exec python -m dingolytics.worker default
fi
}
run_periodic() {
echo "Starting Huey periodic worker (${ENVIRONMENT}) ..."
if [ ${ENVIRONMENT} = "development" ]; then
exec watchmedo auto-restart -d=./redash/ -d=./dingolytics/ -p=*.py -R -- \
python -m dingolytics.worker periodic
else
exec python -m dingolytics.worker periodic
fi
}
run_server() {
echo "Starting application server (${ENVIRONMENT}) ..."
if [ ${ENVIRONMENT} = "development" ]; then
export FLASK_DEBUG=1
exec ./manage.py runserver -h 0.0.0.0
else
# Recycle gunicorn workers every n-th request.
# See http://docs.gunicorn.org/en/stable/settings.html#max-requests
MAX_REQUESTS=${MAX_REQUESTS:-1000}
MAX_REQUESTS_JITTER=${MAX_REQUESTS_JITTER:-100}
TIMEOUT=${GUNICORN_TIMEOUT:-60}
exec gunicorn -b 0.0.0.0:5000 --name redash \
-w${GUNICORN_WEB_WORKERS:-4} redash.main:app \
--max-requests $MAX_REQUESTS --max-requests-jitter \
$MAX_REQUESTS_JITTER --timeout $TIMEOUT
fi
}
case "$1" in
help)
shift
help
;;
manage)
shift
exec ./manage.py $*
;;
shell)
exec ./manage.py shell
;;
run_server)
shift
run_server
;;
run_worker)
shift
run_worker
;;
run_periodic)
shift
run_periodic
;;
*)
exec "$@"
;;
esac