Updated deploy.sh

- Added --dbmakemigrations to do makemigrations
    - Added call to restart celery
This commit is contained in:
PCoder 2017-08-19 18:28:17 +05:30
parent 2b71795431
commit 422b0ca93e
1 changed files with 15 additions and 5 deletions

View File

@ -13,6 +13,7 @@ while true; do
case "$1" in
-h | --help ) HELP=true; shift ;;
-v | --verbose ) VERBOSE=true; shift ;;
-D | --dbmakemigrations ) DB_MAKE_MIGRATIONS=true; shift ;;
-d | --dbmigrate ) DB_MIGRATE=true; shift ;;
-n | --nogit ) NO_GIT=true; shift ;;
-b | --branch ) BRANCH="$2"; shift 2 ;;
@ -31,13 +32,15 @@ if [ "$HELP" == "true" ]; then
echo "options are : "
echo " -h, --help: Print this help message"
echo " -v, --verbose: Show verbose output to stdout. Without this a deploy.log is written to ~/app folder"
echo " -d, --dbmigrate: Do DB migrate"
echo " -n, --nogit: Don't execute git commands. With this --branch has no effect."
echo " -D, --dbmakemigrations: Do DB makemigrations"
echo " -d, --dbmigrate: Do DB migrate. To do both makemigrations and migrate, supply both switches -D and -d"
echo " -n, --nogit: Don't execute git commands. This is used to deploy the current code in the project repo. With this --branch has no effect."
echo " -b, --branch: The branch to pull from origin repo."
exit
fi
echo "BRANCH="$BRANCH
echo "DB_MAKE_MIGRATIONS="$DB_MAKE_MIGRATIONS
echo "DB_MIGRATE="$DB_MIGRATE
echo "NO_GIT="$NO_GIT
echo "VERBOSE="$VERBOSE
@ -45,7 +48,7 @@ echo "VERBOSE="$VERBOSE
# The project directory exists, we pull the specified branch
cd $APP_HOME_DIR
if [ -z "$NO_GIT" ]; then
echo 'We are executing default git commands. Please -no_git to not use this.'
echo 'We are executing default git commands. Please add --nogit to not do this.'
# Save any modified changes before git pulling
git stash
# Fetch all branches/tags
@ -59,16 +62,23 @@ fi
source ~/pyvenv/bin/activate
pip install -r requirements.txt > deploy.log 2>&1
echo "###" >> deploy.log
if [ -z "$DB_MAKE_MIGRATIONS" ]; then
echo 'We are not doing DB makemigrations'
else
echo 'Doing DB makemigrations'
./manage.py makemigrations >> deploy.log 2>&1
echo "###" >> deploy.log
fi
if [ -z "$DB_MIGRATE" ]; then
echo 'We are not doing DB migration'
else
./manage.py makemigrations >> deploy.log 2>&1
echo "###" >> deploy.log
echo 'Doing DB migrate'
./manage.py migrate >> deploy.log 2>&1
echo "###" >> deploy.log
fi
printf 'yes' | ./manage.py collectstatic >> deploy.log 2>&1
echo "###" >> deploy.log
django-admin compilemessages
sudo systemctl restart celery.service
sudo systemctl restart uwsgi