-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·107 lines (78 loc) · 1.71 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
#
set -e
set -o pipefail
HELP="
Runs the webserver for the \"Hash Map as a service\" challenge.
By default, it runs using uWSGI server.
For other run mode, please read the following command line options:
Usage:
docker run ... [MODE] [OPTIONS]
Modes:
-- | uwsgi Runs the application using uWSGI server.
This is the default run mode.
flask Runs the application using Flask.
This is only for development purpose
and always runs in DEBUG mode.
* Any other value will be treated as a normal
command to execute inside the Docker container.
Options:
--debug Runs the application in DEBUG mode.
-h | -? | --help Prints this help message."
#
# Functions:
#
function init()
{
mkdir -p "${DATA_VOLUME}/collections" \
"${DATA_VOLUME}/logs" \
"${DATA_VOLUME}/tmp"
chown -R www-data:www-data "${DATA_VOLUME}"
}
function run-flask()
{
export DEBUG="true"
su-exec www-data python run.py ${@}
}
function run-uwsgi()
{
local ARGS=()
while [[ ${#} -gt 0 ]]
do
case "${1}" in
--debug)
export DEBUG="true"
;;
*)
ARGS+=("${1}")
;;
esac
shift
done
set -- "${ARGS[@]}"
uwsgi --ini uwsgi.ini ${@}
}
#
# Execution:
#
init
case "${1}" in
-h | -? | --help)
echo "${HELP}"
exit 0
;;
-- | uwsgi)
shift
run-uwsgi ${@}
;;
-*)
run-uwsgi ${@}
;;
flask)
shift
run-flask ${@}
;;
*)
exec ${@}
;;
esac