From 9d9cbb8db8c9e72d7331c611189ce28aab32ab7c Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Sat, 17 Mar 2018 11:45:40 +0100 Subject: [PATCH] Add fabfile --- fabfile.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 fabfile.py diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 0000000..edaa2a0 --- /dev/null +++ b/fabfile.py @@ -0,0 +1,25 @@ +from contextlib import contextmanager as _contextmanager +from fabric.api import run, sudo, env, cd, prefix + +env.use_ssh_config = True +env.hosts = ['dreamcast.neuf.no'] +env.project_path = '/var/www/neuf.no/kassa' +env.user = 'gitdeploy' +env.activate = 'source {}/venv/bin/activate'.format(env.project_path) + + +@_contextmanager +def virtualenv(): + with cd(env.project_path), prefix(env.activate): + yield + + +def deploy(): + with virtualenv(): + run('git pull') # Get source + run('pip install -r requirements.txt') # install deps in virtualenv + run('umask 022; python manage.py collectstatic --noinput') # Collect static + run('python manage.py migrate') # Run DB migrations + + # Reload + sudo('/usr/bin/supervisorctl pid kassa.neuf.no | xargs kill -HUP', shell=False)