Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import with_statement
- from fabric.api import *
- from fabric.contrib import django
- env.hosts = ["user@example.com"]
- REMOTE_PROJECT_ROOT = '/path/to/project/root/'
- def _run_django_prod(command):
- """ Run a django command remotely using production settings """
- return run("PYTHONPATH=$PYTHONPATH:src bin/django-admin.py %s --settings=myapp.production" % command)
- def deploy():
- # will fail if files are changed and not checked in
- # (it still wouldn't detect untracked files!)
- local("git diff-index --quiet HEAD")
- # archive HEAD
- local("git archive --format=tar HEAD | gzip > /tmp/papu.tgz")
- # send to server
- put('/tmp/papu.tgz', '/tmp/')
- with cd(REMOTE_PROJECT_ROOT):
- # unpack
- run('tar xzf /tmp/papu.tgz')
- _run_django_prod('syncdb')
- _run_django_prod('migrate')
- _run_django_prod('collectstatic --noinput')
- # restart the server - will fail if server wasn't running
- with settings(warn_only=True):
- run('pkill python')
Add Comment
Please, Sign In to add comment