Skip to content

Commit d8027b9

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents 90d8b5d + 1bfcc19 commit d8027b9

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

celery_start_prod.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Virtual env path
4+
VIRTUAL_ENV=/srv/webapps/elvisdb/prod/.env
5+
PROJECT_PATH=/srv/webapps/elvisdb/prod
6+
# Activate
7+
source ${VIRTUAL_ENV}/bin/activate
8+
# Move to project directory
9+
cd ${PROJECT_PATH}
10+
# Run your worker... old: exec celery worker -A elvis -l DEBUG --loglevel=INFO
11+
exec celery worker -A elvis -l info --pidfile="/run/celery/%n-prod.pid"

deploy_prod.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
ENV="prod"
4+
BASE_DIR="/srv/webapps/elvisdb"
5+
6+
# Save a backup
7+
mv "${BASE_DIR}/${ENV}" "${BASE_DIR}/old/${ENV}_$(date +%s)"
8+
9+
# Clone the repo
10+
git clone git@github.com:ELVIS-Project/elvis-database.git ${BASE_DIR}/${ENV}
11+
12+
# Set up the virtualenv
13+
virtualenv -p python3 ${BASE_DIR}/${ENV}/.env
14+
15+
# Install requirements
16+
source ${BASE_DIR}/${ENV}/.env/bin/activate
17+
pip install -r ${BASE_DIR}/${ENV}/requirements.txt
18+
19+
# Perform Django management tasks
20+
python ${BASE_DIR}/${ENV}/manage.py collectstatic --noinput
21+
python ${BASE_DIR}/${ENV}/manage.py migrate --noinput
22+
23+
# Restart supervisor processes
24+
sudo supervisorctl restart elvis-db-${ENV}
25+
sudo supervisorctl restart elvis-celery-${ENV}
26+
27+
# Permissions
28+
chown $USER:elvisDB ${BASE_DIR}/${ENV}
29+
chmod 775 ${BASE_DIR}/${ENV}
30+
31+
echo "Elvis DB ${ENV} Deployment Complete"

gunicorn_start_prod.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
NAME="elvisdb_prod" # name of the application
4+
VIRTUAL_ENV=/srv/webapps/elvisdb/prod/.env # name of virtual_env directory
5+
DJANGODIR=/srv/webapps/elvisdb/prod/ # Django project directory
6+
SOCKFILE=/var/sockets/prod-elvis-db.sock # we will communicte using this unix socket
7+
USER=elvis # the user to run as
8+
GROUP=elvisDB # the group to run as
9+
NUM_WORKERS=10 # how many worker processes should Gunicorn spawn
10+
DJANGO_SETTINGS_MODULE=elvis.settings # which settings file should Django use
11+
DJANGO_WSGI_MODULE=elvis.wsgi # WSGI module name
12+
13+
echo "Starting $NAME"
14+
15+
# Activate the virtual environment
16+
cd $DJANGODIR
17+
source ${VIRTUAL_ENV}/bin/activate
18+
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
19+
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
20+
21+
# Create the run directory if it doesn't exist
22+
#RUNDIR=$(dirname $SOCKFILE)
23+
#test -d $RUNDIR || mkdir -p $RUNDIR
24+
25+
# Start your Django Unicorn
26+
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
27+
exec ${VIRTUAL_ENV}/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
28+
--name $NAME \
29+
--workers $NUM_WORKERS \
30+
--user=$USER --group=$GROUP \
31+
--log-level=debug \
32+
--bind=unix:$SOCKFILE

0 commit comments

Comments
 (0)