-
Notifications
You must be signed in to change notification settings - Fork 2
/
dockercmd
executable file
·60 lines (53 loc) · 1.32 KB
/
dockercmd
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
#!/bin/bash
set -ex
# fix bug added 0.16.2 -- removed 0.17.1
# we upgraded django-oauth2-toolkit to v2 in 0.16.2
# and then downgraded it back to v1 after discovering some breaking changes.
MARKER=/app/var/did_reset_oauth_provider_migrations
if [ ! -f $MARKER ] ; then
./manage.py migrate oauth2_provider zero || true
date > $MARKER
fi
./manage.py migrate
# poor man's cron
(
set +e
while true; do
sleep 444
./manage.py clearsessions
./manage.py cleartokens
done
) &
./manage.py resethealthchecks
(
set +e
while true; do
sleep 120
./manage.py updatehealthchecks
done
) &
# when running, always use gunicorn, to avoid
# > AssertionError: X is a "hop-by-hop" header;
# that comes from all uWSGI implementations (django server and waitress)
if [[ "$DEBUG" == "true" ]]; then
# sometimes auto-reload means crashing containers (because of syntax errors)
while true; do
gunicorn --reload \
--access-logfile '-' \
--error-logfile '-' \
--log-level 'info' \
--threads 20 \
--timeout 600 \
-b 0.0.0.0:8000 \
liquidcore.site.wsgi:application
sleep 5
done
else
# in production we want whole container resets on gunicorn failure
exec gunicorn \
--error-logfile '-' \
--threads 20 \
--timeout 600 \
-b 0.0.0.0:8000 \
liquidcore.site.wsgi:application
fi