forked from EFForg/call-congress
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathentrypoint.sh
executable file
·39 lines (31 loc) · 921 Bytes
/
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
#!/bin/bash
#set -e
if [ ! -e "/opt/dev.db" ]; then
flask migrate up
flask assets build
fi
start_ngrok() {
(
ngrok http --log stdout --log-level debug 5000 \
| grep --line-buffered -oE 'https://[[:alnum:]]+.ngrok.io'
) >/var/log/ngrok.log &
while [ -z "$(cat /var/log/ngrok.log)" ]; do
echo "Waiting on ngrok..." >&2
sleep 0.2
done
grep -oE '[[:alnum:]]+.ngrok.io' /var/log/ngrok.log
}
case "$FLASK_ENV" in
"production")
flask loadpoliticaldata
exec bash -l -c "gunicorn call_server.wsgi:application --worker-class=gthread"
;;
"development-expose")
external_host="$(start_ngrok)"
echo "External address is https://$external_host" >&2
exec bash -l -c "export SERVER_NAME=$external_host; flask run --host=0.0.0.0"
;;
"development" | "")
exec bash -l -c "flask run"
;;
esac