-
Notifications
You must be signed in to change notification settings - Fork 5
/
deploy_dev.sh
executable file
·55 lines (36 loc) · 1.39 KB
/
deploy_dev.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
#!/usr/bin/env bash
ENV="dev"
BASE_DIR="/srv/webapps/elvisdb"
printf "Beginning ${ENV} Deployment\n"
printf "Dumping database to disk. This may take a while...\n"
# Dump the database
source ${BASE_DIR}/${ENV}/.env/bin/activate
python ${BASE_DIR}/${ENV}/manage.py dumpdata > ${BASE_DIR}/${ENV}/database_$(date +%s).json
deactivate
printf "Saving code backup...\n"
# Save a backup
mv "${BASE_DIR}/${ENV}" "${BASE_DIR}/old/${ENV}_$(date +%s)"
printf "Cloning repo from GitHub...\n"
# Clone the repo
git clone -b dev [email protected]:ELVIS-Project/elvis-database.git ${BASE_DIR}/${ENV}
printf "Installing Python requirements...\n"
# Set up the virtualenv
virtualenv -p python3 ${BASE_DIR}/${ENV}/.env
# Install requirements
source ${BASE_DIR}/${ENV}/.env/bin/activate
pip install -r ${BASE_DIR}/${ENV}/requirements.txt
printf "Performing Django management tasks...\n"
# Perform Django management tasks
python ${BASE_DIR}/${ENV}/manage.py collectstatic --noinput
python ${BASE_DIR}/${ENV}/manage.py migrate --noinput
# Clear the Cache
python ${BASE_DIR}/${ENV}/manage.py clear_cache
printf "Starting application processes...\n"
# Restart supervisor processes
sudo supervisorctl restart elvis-db-${ENV}
sudo supervisorctl restart elvis-celery-${ENV}
printf "File system cleanup...\n"
# Permissions
chown $USER:elvisDB ${BASE_DIR}/${ENV}
chmod 775 ${BASE_DIR}/${ENV}
printf "Elvis DB ${ENV} Deployment Complete\n"