Commit 2356bbf018e180f7e093232b51ee3bc062b88536
1 parent
29840f40
Exists in
master
and in
39 other branches
Adding fabfile
Showing
1 changed file
with
50 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,50 @@ |
| 1 | + | |
| 2 | +from fabric.api import run, sudo, env | |
| 3 | +from fabric.contrib.files import exists | |
| 4 | +from fabric.context_managers import prefix, cd | |
| 5 | +from fabric.decorators import with_settings | |
| 6 | + | |
| 7 | +env.user = 'colab' # key depends on env | |
| 8 | +env.use_shell = False | |
| 9 | + | |
| 10 | +environments = { | |
| 11 | + 'dev': { | |
| 12 | + 'hosts': ['127.0.0.1'], | |
| 13 | + 'port': 2222, | |
| 14 | + 'key_filename': '~/.vagrant.d/insecure_private_key', | |
| 15 | + }, | |
| 16 | + 'live': { | |
| 17 | + 'hosts': [], #TODO | |
| 18 | + 'key_filename': '~/.ssh/id_rsa', | |
| 19 | + }, | |
| 20 | +} | |
| 21 | + | |
| 22 | + | |
| 23 | +SOURCE_VENV = 'source /usr/local/bin/virtualenvwrapper.sh' | |
| 24 | +WORKON_COLAB = '{} && workon colab'.format(SOURCE_VENV) | |
| 25 | + | |
| 26 | + | |
| 27 | +def environment(name): | |
| 28 | + env.update(environments[name]) | |
| 29 | + env.environment = name | |
| 30 | +environment('dev') | |
| 31 | + | |
| 32 | + | |
| 33 | +def install(): | |
| 34 | + if not exists('~colab/.virtualenvs/colab'): | |
| 35 | + with prefix(SOURCE_VENV): | |
| 36 | + run('mkvirtualenv colab') | |
| 37 | + | |
| 38 | + if not exists('~colab/colab'): | |
| 39 | + run('git clone https://github.com/TracyWebTech/colab ~colab/colab') | |
| 40 | + | |
| 41 | + sudo('supervisorctl reload', shell=False ) | |
| 42 | + | |
| 43 | + | |
| 44 | +def deploy(): | |
| 45 | + with cd('~colab/colab'): | |
| 46 | + run('git pull') | |
| 47 | + | |
| 48 | + with prefix(WORKON_COLAB): | |
| 49 | + run('pip install -r ~colab/colab/requirements.txt') | |
| 50 | + | ... | ... |