2010-03-02 14:31:11 +00:00
|
|
|
#this is a fabfile, use it with fab from http://fabfile.org/
|
|
|
|
#
|
|
|
|
# initial setup:
|
|
|
|
# fab production setup
|
|
|
|
#
|
|
|
|
# deploy changes:
|
|
|
|
# fab production deploy
|
|
|
|
#
|
|
|
|
|
|
|
|
from os.path import join
|
|
|
|
from fabric.api import run, local, sudo, put, env
|
|
|
|
|
|
|
|
env.project_name = 'index'
|
|
|
|
|
|
|
|
def production():
|
|
|
|
env.hosts = ['%(project_name)s@camp.r-w-x.org'%env, ]
|
2010-03-02 17:01:49 +00:00
|
|
|
env.project_root = '/srv/%(project_name)s'%env
|
2010-03-02 14:31:11 +00:00
|
|
|
|
|
|
|
def bzr_push():
|
2010-03-02 17:01:49 +00:00
|
|
|
local('bzr push bzr+ssh://%(project_name)s@%(host)s%(project_root)s'%env)
|
2010-03-02 14:31:11 +00:00
|
|
|
|
|
|
|
def bzr_update():
|
|
|
|
run('cd %(project_root)s;bzr update'%env)
|
|
|
|
|
|
|
|
def virtual_run(cmd, *a, **kw):
|
|
|
|
cmd = 'cd %s; source bin/activate; %s' % (env.project_root, cmd)
|
|
|
|
run(cmd, *a, **kw)
|
|
|
|
|
|
|
|
def update_requirements():
|
|
|
|
run('pip -E %(project_root)s install -r %(project_root)s/requirements.txt'%env)
|
|
|
|
|
|
|
|
def setup():
|
|
|
|
"""
|
|
|
|
Setup a fresh virtualenv
|
|
|
|
"""
|
2010-03-02 17:01:49 +00:00
|
|
|
local('bzr push --use-existing-dir bzr+ssh://%(project_name)s@%(host)s%(project_root)s'%env)
|
2010-03-02 14:31:11 +00:00
|
|
|
run('cd %(project_root)s; test -e .bzr/checkout || bzr checkout'%env)
|
|
|
|
run('virtualenv %(project_root)s'%env)
|
|
|
|
put(join('settings', '%(host)s.py'%env), join(env.project_root, env.project_name, 'local_settings.py'))
|
|
|
|
update_requirements()
|
|
|
|
|
|
|
|
def deploy():
|
|
|
|
bzr_push()
|
|
|
|
bzr_update()
|
2010-03-02 17:01:49 +00:00
|
|
|
virtual_run('python %(project_root)s/manage.py syncdb;python %(project_root)s/manage.py migrate'%env)
|
2010-03-02 14:31:11 +00:00
|
|
|
run('touch %(project_root)s/wsgi/django.wsgi'%env)
|