diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2011-01-20 11:06:19 +0200 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2011-01-20 11:06:19 +0200 |
| commit | f6b389233e2d8ac3b4d29322d86fceb2e2de7a37 (patch) | |
| tree | 2228ea145cad6b89e6ce188694637633dbcf04db /fabfile.py | |
initial commit
Diffstat (limited to 'fabfile.py')
| -rw-r--r-- | fabfile.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 0000000..0a25331 --- /dev/null +++ b/fabfile.py @@ -0,0 +1,43 @@ +def bootstrap(): + """ initialize remote host environment (virtualenv, deploy, update) """ + require('root', provided_by=('staging', 'production')) + run('mkdir -p %(root)s' % env) + run('mkdir -p %s' % os.path.join(env.home, 'www', 'log')) + create_virtualenv() + deploy() + update_requirements() + + +def create_virtualenv(): + """ setup virtualenv on remote host """ + require('virtualenv_root', provided_by=('staging', 'production')) + args = '--clear --distribute' + run('virtualenv %s %s' % (args, env.virtualenv_root)) + + +def deploy(): + """ rsync code to remote host """ + require('root', provided_by=('staging', 'production')) + if env.environment == 'production': + if not console.confirm('Are you sure you want to deploy production?', + default=False): + utils.abort('Production deployment aborted.') + extra_opts = '--omit-dir-times' + rsync_project( + env.root, + exclude=RSYNC_EXCLUDE, + delete=True, + extra_opts=extra_opts, + ) + touch() + + +def update_requirements(): + """ update external dependencies on remote host """ + require('code_root', provided_by=('staging', 'production')) + requirements = os.path.join(env.code_root, 'requirements') + with cd(requirements): + cmd = ['pip install'] + cmd += ['-E %(virtualenv_root)s' % env] + cmd += ['--requirement %s' % os.path.join(requirements, 'apps.txt')] + run(' '.join(cmd))
\ No newline at end of file |
