-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfabfile.py
More file actions
45 lines (41 loc) · 1006 Bytes
/
fabfile.py
File metadata and controls
45 lines (41 loc) · 1006 Bytes
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
from __future__ import with_statement
from fabric.api import *
hosts = {
'production': ['72.51.30.180'],
'staging': ['72.51.30.179'],
'dev': ['174.129.30.16']
}
locations = {
'production': '/data/web/hipsell.com/api/',
'staging': '/data/web/s.hipsell.com/api/',
'dev': '/var/hipsell/hs-server/'
}
restarts = {
'production': 'supervisorctl restart api',
'staging': 'supervisorctl restart api-staging',
'dev': 'restart hs-server'
}
pulls = {
'production': 'git pull origin master',
'staging': 'git pull origin master',
'dev': 'git pull origin develop'
}
users = {
'production': 'web',
'staging': 'web'
}
@task
def deploy(mode):
# Sanity check
if not mode in locations:
raise Error('Bad mode %s' % mode)
# Set the host lists
kwargs = {}
kwargs['host_string'] = ','.join(hosts[mode])
if mode in users:
kwargs['user'] = users[mode]
with settings(**kwargs):
# Do the deploy
with cd(locations[mode]):
run(pulls[mode])
sudo(restarts[mode])