|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -echo "===== Cloning Access Modules =====" |
4 | | -python scripts/clone_access_modules.py |
| 3 | +LOG_FILE=/ebs/logs/enigma.log |
| 4 | +CONTAINER_HASH=$(echo $RANDOM | md5sum | head -c 20) |
5 | 5 |
|
6 | | -echo "===== Install requirements for access modules =====" |
7 | | -pip install -r Access/access_modules/requirements.txt --no-cache-dir --ignore-installed |
| 6 | +function log() { |
| 7 | + echo "$(date): $CONTAINER_HASH $@" 2>&1 | tee $LOG_FILE |
| 8 | +} |
8 | 9 |
|
9 | | -echo "===== Ensure DB State =====" |
10 | | -python manage.py createcachetable |
11 | | -python manage.py migrate # Apply database migrations |
| 10 | +function prepend() { |
| 11 | + while read line; do |
| 12 | + echo "${line}" |
| 13 | + echo "$(date): $CONTAINER_HASH -- ${line}" >> $LOG_FILE |
| 14 | + done |
| 15 | +} |
12 | 16 |
|
13 | | -echo "===== Ensure Static Files =====" |
14 | | -python manage.py collectstatic --clear --noinput # clearstatic files |
15 | | -python manage.py collectstatic --noinput # collect static files |
| 17 | + |
| 18 | +log "===== Cloning Access Modules =====" |
| 19 | +python scripts/clone_access_modules.py 2>&1 | prepend |
| 20 | + |
| 21 | +log "===== Install requirements for access modules =====" |
| 22 | +pip install -r Access/access_modules/requirements.txt --no-cache-dir --ignore-installed 2>&1 | prepend |
| 23 | + |
| 24 | +log "===== Ensure DB State =====" |
| 25 | +python manage.py createcachetable 2>&1 | prepend |
| 26 | +python manage.py migrate 2>&1 | prepend |
| 27 | + |
| 28 | +log "===== Ensure Static Files =====" |
| 29 | +python manage.py collectstatic --clear --noinput 2>&1 | prepend |
| 30 | +python manage.py collectstatic --noinput 2>&1 | prepend |
16 | 31 |
|
17 | 32 | # directory for gunicorn logs and django app logs |
18 | | -echo "===== Ensure Logs =====" |
| 33 | +log "===== Ensure Logs =====" |
19 | 34 | touch /ebs/logs/enigma.log |
20 | | -tail -n 0 -f /ebs/logs/enigma.log & |
21 | 35 |
|
22 | | -echo "===== Running Service =====" |
23 | | -eval "$@" |
| 36 | +log "===== Running Service =====" |
| 37 | +eval "$@" 2>&1 | prepend |
0 commit comments