forked from dsmrreader/dsmr-reader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-deploy.sh
executable file
·82 lines (61 loc) · 1.84 KB
/
post-deploy.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
#!/bin/bash
echo ""
echo ""
echo " --- Checking whether VirtualEnv is activated."
python -c 'import sys; exit_code = 0 if hasattr(sys, "real_prefix") else 1; sys.exit(exit_code);'
if [ $? -ne 0 ]; then
echo " [i] ----- Activating 'dsmrreader' VirtualEnv..."
source ~/.virtualenvs/dsmrreader/bin/activate
if [ $? -ne 0 ]; then
echo " [!] FAILED to switch to 'dsmrreader' VirtualEnv (is it installed?)"
exit;
fi
fi
echo ""
echo ""
echo " --- Checking & synchronizing base requirements for changes."
pip3 install -r dsmrreader/provisioning/requirements/base.txt
echo ""
echo ""
echo " --- Checking & synchronizing database changes/migrations."
./manage.py migrate --noinput
echo ""
echo ""
echo " --- Checking & synchronizing static file changes."
./manage.py collectstatic --noinput
echo ""
echo ""
echo " --- Reloading app code..."
# Sending a HANGUP signal to Gunicorn's master process will gracefully reload its children.
echo ""
echo " * Reloading Gunicorn (webinterface)..."
if [ -f /var/tmp/gunicorn--dsmr_webinterface.pid ];
then
cat /var/tmp/gunicorn--dsmr_webinterface.pid | xargs kill -HUP
echo " [x] Done!"
else
echo " !-- PID file does not exist (yet)"
fi
# Management commands have some builtin mechanism as well for this.
echo ""
echo " * Reloading backend process..."
if [ -f /var/tmp/dsmrreader--dsmr_backend.pid ];
then
cat /var/tmp/dsmrreader--dsmr_backend.pid | xargs kill -HUP
echo " [x] Done!"
else
echo " !-- PID file does not exist (yet)"
fi
echo ""
echo " * Reloading datalogger process..."
if [ -f /var/tmp/dsmrreader--dsmr_datalogger.pid ];
then
cat /var/tmp/dsmrreader--dsmr_datalogger.pid | xargs kill -HUP
echo " [x] Done!"
else
echo " !-- PID file does not exist (yet)"
fi
echo ""
echo ""
echo " --- Clearing cache..."
./manage.py dsmr_frontend_clear_cache