Skip to content

Instantly share code, notes, and snippets.

@joepreludian
Created May 25, 2015 10:13
Show Gist options
  • Select an option

  • Save joepreludian/085a93afebfb1047913a to your computer and use it in GitHub Desktop.

Select an option

Save joepreludian/085a93afebfb1047913a to your computer and use it in GitHub Desktop.
Simplest Fabfile template for django projects
# -*- encoding: utf8 -*-
from fabric.api import env, settings, cd
from fabric.operations import run, sudo
env.hosts = ['trilhus@helena']
env.project_dir = '/home/trilhus/webapps/projectname'
env.branch = 'master'
def production():
env.project_dir = '/home/trilhus/webapps/project'
env.branch = 'master'
def run_in_virtualenv(command):
run('%s/env/bin/%s' % (env.project_dir, command))
def deploy():
with cd(env.project_dir):
run('git pull origin %s' % env.branch)
run_in_virtualenv('pip install -r requirements.pip')
run_in_virtualenv('python manage.py migrate')
run_in_virtualenv('python manage.py collectstatic --noinput')
run('sudo service nginx restart')
run('sudo service supervisord restart')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment