Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
AFFogarty committed Feb 19, 2016
2 parents 90d8b5d + 1bfcc19 commit d8027b9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
11 changes: 11 additions & 0 deletions celery_start_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Virtual env path
VIRTUAL_ENV=/srv/webapps/elvisdb/prod/.env
PROJECT_PATH=/srv/webapps/elvisdb/prod
# Activate
source ${VIRTUAL_ENV}/bin/activate
# Move to project directory
cd ${PROJECT_PATH}
# Run your worker... old: exec celery worker -A elvis -l DEBUG --loglevel=INFO
exec celery worker -A elvis -l info --pidfile="/run/celery/%n-prod.pid"
31 changes: 31 additions & 0 deletions deploy_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

ENV="prod"
BASE_DIR="/srv/webapps/elvisdb"

# Save a backup
mv "${BASE_DIR}/${ENV}" "${BASE_DIR}/old/${ENV}_$(date +%s)"

# Clone the repo
git clone [email protected]:ELVIS-Project/elvis-database.git ${BASE_DIR}/${ENV}

# 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

# Perform Django management tasks
python ${BASE_DIR}/${ENV}/manage.py collectstatic --noinput
python ${BASE_DIR}/${ENV}/manage.py migrate --noinput

# Restart supervisor processes
sudo supervisorctl restart elvis-db-${ENV}
sudo supervisorctl restart elvis-celery-${ENV}

# Permissions
chown $USER:elvisDB ${BASE_DIR}/${ENV}
chmod 775 ${BASE_DIR}/${ENV}

echo "Elvis DB ${ENV} Deployment Complete"
32 changes: 32 additions & 0 deletions gunicorn_start_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

NAME="elvisdb_prod" # name of the application
VIRTUAL_ENV=/srv/webapps/elvisdb/prod/.env # name of virtual_env directory
DJANGODIR=/srv/webapps/elvisdb/prod/ # Django project directory
SOCKFILE=/var/sockets/prod-elvis-db.sock # we will communicte using this unix socket
USER=elvis # the user to run as
GROUP=elvisDB # the group to run as
NUM_WORKERS=10 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=elvis.settings # which settings file should Django use
DJANGO_WSGI_MODULE=elvis.wsgi # WSGI module name

echo "Starting $NAME"

# Activate the virtual environment
cd $DJANGODIR
source ${VIRTUAL_ENV}/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

# Create the run directory if it doesn't exist
#RUNDIR=$(dirname $SOCKFILE)
#test -d $RUNDIR || mkdir -p $RUNDIR

# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec ${VIRTUAL_ENV}/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug \
--bind=unix:$SOCKFILE

0 comments on commit d8027b9

Please sign in to comment.