-
Notifications
You must be signed in to change notification settings - Fork 2
/
fabfile.py
88 lines (68 loc) · 2.33 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from fabric.api import run, cd, local, prefix, task, hosts
from fabric.colors import green
settings = {
'paths': {
'sugar': {
'bs': '/data/dev/bs'
}
}
}
def _run(locally):
if locally:
return local
return run
@task
def push(branch='master', remote='origin', locally=True):
print(green('[x] PUSHING repository'))
_run(locally)("git push %s %s" % (remote, branch))
@task
def pull(branch='master', remote='origin', locally=True):
print(green('[x] PULLING repository'))
_run(locally)("git pull %s %s" % (remote, branch))
@task
def sync(branch='master', remote='origin', locally=True):
print(green('[x] SYNCING repository'))
pull(branch, remote, locally)
push(branch, remote, locally)
## for updating dev server on sugar from local
# e.g:
# update bioscript and restart service: $ fab update deploy
# update all bioscript and all libraires: $ fab update:libs=True (fab update:True)
sugar_libs = ['bbcflib', 'bsPlugins', 'tw2.bs']
@task
@hosts('[email protected]')
def sugar_sync_repo(project='bs'):
path = settings['paths']['sugar'][project]
with cd(path):
pull(locally=False)
push(locally=False)
@task(alias='supdate')
@hosts('[email protected]')
def sugar_update(libs=False, project='bs'):
print(green('[x] Updating bioscript ...'))
path = settings['paths']['sugar'][project]
with cd(path):
pull(locally=False)
if libs:
with cd('/data/dev/libs'):
print(green('[x] Updating libs on sugar ...'))
for lib in sugar_libs:
print(green('\t[x] %s' % lib))
with cd(lib):
pull(locally=False)
@task(alias='sdeploy')
@hosts('[email protected]')
def deploy_sugar(cmd='restart', project='bs'):
print(green('[x] Service %sing on sugar ... ' % cmd))
path = settings['paths']['sugar'][project]
with cd(path):
with prefix('workon %s' % project):
_run(locally=False)("./webserverctl %s && ./workerctl %s" % (cmd, cmd))
@task(alias='webserver')
@hosts('[email protected]')
def deploy_sugar(cmd='restart', project='bs'):
print(green('[x] Service %sing on sugar ... ' % cmd))
path = settings['paths']['sugar'][project]
with cd(path):
with prefix('workon %s' % project):
_run(locally=False)("./webserverctl %s" % cmd)