-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev'
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |