Skip to content

Instantly share code, notes, and snippets.

@pellaeon
Created February 20, 2015 06:00
Show Gist options
  • Save pellaeon/7502acb2d025fa46021e to your computer and use it in GitHub Desktop.
Save pellaeon/7502acb2d025fa46021e to your computer and use it in GitHub Desktop.
Django uwsgi post-receive git deploy hook (FreeBSD)
#!/bin/bash
export GIT_WORK_TREE=/srv/xxxx.tw
git checkout -f master
cd $GIT_WORK_TREE
cp /repos/settings.json ${GIT_WORK_TREE}/luroufan/settings/
if [ ! -d ${GIT_WORK_TREE}/venv ]; then
virtualenv venv
fi
. venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
if [ ! -d ${GIT_WORK_TREE}/static ]; then
mkdir ${GIT_WORK_TREE}/static
fi
python manage.py collectstatic --noinput
if [ -f /tmp/luroufan.pid ]; then
sudo -u www uwsgi --reload /tmp/luroufan.pid
else
sudo -u www uwsgi --ini ${GIT_WORK_TREE}/luroufan/uwsgi.ini
fi
git ALL=(www) NOPASSWD: /usr/local/bin/uwsgi
[uwsgi]
chdir=/srv/xxxx.tw
virtualenv=/srv/xxxx.tw/venv
module=luroufan.wsgi:application
master=True
pidfile=/tmp/luroufan.pid
socket=/tmp/luroufan.sock
processes=10
vacuum=True
daemonize=/var/log/uwsgi/luroufan.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment