Created
July 24, 2012 11:30
-
-
Save carlosrberto/3169477 to your computer and use it in GitHub Desktop.
Fabfile exemplo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import os | |
from fabric.api import run, env, local | |
# local | |
env.local_root = os.path.abspath( os.path.dirname(__file__) ) | |
# remote | |
env.hosts = [ | |
'[email protected]', | |
# '[email protected]', | |
] | |
env.home_dir = '/home/pubdesign/' | |
env.repository = 'git://github.com/django/django.git' | |
env.virtualenv = '/home/pubdesign/env/' | |
env.requirements = '/home/pubdesign/project/requirements.txt' | |
def commit(): | |
local( 'cd %s && git add . && git commmit -m "asdasdasd"' % env.local_root ) | |
def deploy(): | |
run('cd %s && git clone %s project' % (env.home_dir, env.repository)) | |
requirements() | |
collectstatic() | |
syncdb() | |
migrate(fake=True) | |
# restart service uwsgi | |
def up(): | |
deploy_code() | |
requirements() | |
collectstatic() | |
migrate() | |
# restart service uwsgi | |
def deploy_code(): | |
run('cd %s && git pull' % env.home_dir) | |
def run_env(cmd): | |
run('source %sbin/activate && %s' % (env.virtualenv, cmd)) | |
def requirements(): | |
run_env('pip install -r %s' % env.requirements) | |
def collectstatic(): | |
manage_py('collectstatic --noinput') | |
def migrate(fake=False): | |
if fake: | |
manage_py('migrate --fake') | |
else: | |
manage_py('migrate') | |
def syncdb(): | |
manage_py('syncdb --all') | |
def manage_py(cmd): | |
run('%sbin/python %sproject/manage.py %s' % (env.home_dir, env.virtualenv, cmd)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment