-
Notifications
You must be signed in to change notification settings - Fork 254
/
reset.sh
executable file
·86 lines (74 loc) · 2.83 KB
/
reset.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
#! /bin/bash
export DA_ROOT="${DA_ROOT:-/usr/share/docassemble}"
export DA_DEFAULT_LOCAL="local3.10"
export DA_CONFIG_FILE="${DA_CONFIG:-${DA_ROOT}/config/config.yml}"
export DA_ACTIVATE="${DA_PYTHON:-${DA_ROOT}/${DA_DEFAULT_LOCAL}}/bin/activate"
source "${DA_ACTIVATE}"
export CONTAINERROLE=":${CONTAINERROLE:-all}:"
export HOME=/var/www
source /dev/stdin < <(python -m docassemble.base.read_config "$DA_CONFIG_FILE")
if [ "${DAREADONLYFILESYSTEM:-false}" == "true" ]; then
echo "Will not reset because read-only file system" >&2
exit 0
fi
if [ "${DASUPERVISORUSERNAME:-null}" != "null" ]; then
SUPERVISORCMD="supervisorctl --serverurl http://localhost:9001 --username ${DASUPERVISORUSERNAME} --password ${DASUPERVISORPASSWORD}"
else
SUPERVISORCMD="supervisorctl --serverurl http://localhost:9001"
fi
if [ "${DAROOTOWNED:-false}" == "true" ]; then
if [ "${DAALLOWUPDATES:-true}" == "true" ] \
|| [ "${DAENABLEPLAYGROUND:-true}" == "true" ] \
|| [ "${DAALLOWCONFIGURATIONEDITING:-true}" == "true" ]; then
echo "`date` starting docassemble.webapp.restart" >&2
python -m docassemble.webapp.restart
echo "`date` finished docassemble.webapp.restart" >&2
fi
else
echo "`date` starting docassemble.webapp.restart" >&2
python -m docassemble.webapp.restart
echo "`date` finished docassemble.webapp.restart" >&2
fi
if [ "${DAALLOWUPDATES:-true}" == "true" ]; then
if [ "${PIPINDEXURL:-null}" != "null" ]; then
pip config set global.index-url "${PIPINDEXURL}"
else
pip config unset global.index-url &> /dev/null
fi
if [ "${PIPEXTRAINDEXURLS:-null}" != "null" ]; then
pip config set global.extra-index-url "${PIPEXTRAINDEXURLS}"
else
pip config unset global.extra-index-url &> /dev/null
fi
fi
if [[ $CONTAINERROLE =~ .*:(all|celery):.* ]]; then
echo "`date` stopping celery" >&2
${SUPERVISORCMD} stop celery || exit 1
echo "`date` stopping celerysingle" >&2
${SUPERVISORCMD} stop celerysingle || exit 1
if [[ $CONTAINERROLE =~ .*:(all|rabbitmq):.* ]]; then
echo "`date` stopping rabbitmq" >&2
${SUPERVISORCMD} stop rabbitmq || exit 1
fi
sleep 1
if [[ $CONTAINERROLE =~ .*:(all|rabbitmq):.* ]]; then
echo "`date` starting rabbitmq" >&2
${SUPERVISORCMD} start rabbitmq || exit 1
fi
sleep 1
echo "`date` starting celery" >&2
${SUPERVISORCMD} start celery || exit 1
echo "`date` starting celerysingle" >&2
${SUPERVISORCMD} start celerysingle || exit 1
echo "`date` finished resetting background task system" >&2
fi
if [[ $CONTAINERROLE =~ .*:(all|web):.* ]]; then
echo "`date` stopping websockets" >&2
${SUPERVISORCMD} stop websockets || exit 1
sleep 1
echo "`date` starting websockets" >&2
${SUPERVISORCMD} start websockets || exit 1
echo "`date` finished resetting websockets" >&2
fi
echo "`date` finished reset process" >&2
exit 0