forked from symroe/nhs-prescriptions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
56 lines (45 loc) · 1.2 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
import sys
from fabric.api import *
from fabric.colors import red, green
import requests
web = ['openhealthcare.org.uk']
serves = [
'http://openhealthcare.org.uk',
'http://prescriptions.openhealthcare.org.uk'
]
def manage(what):
"""
Run a manage.py command
Return: None
Exceptions: None
"""
with cd('/var/apps/nhs-prescriptions/nhs-prescriptions/nhs'):
run('./venv/bin/python manage.py {0}'.format(what))
@hosts(web)
def deploy():
"""
Make it so!
Return: None
Exceptions: None
"""
# FIXME stop deploying out of git for atomicity.
with cd('/var/apps/nhs-prescriptions/nhs-prescriptions'):
sudo('git pull github master') #not ssh - key stuff
sudo('chown ross:ross .') # !!! FIXME
sudo('/etc/init.d/apache2 reload')
for site in serves:
req = requests.get(site)
if req.status_code != 200:
print red("Cripes! something just blew up Larry! ({0})".format(site))
sys.exit(1)
print green("Deploy-o-rama!")
@hosts(web)
def migrate():
"""
Update to latest please
Return: None
Exceptions: None
"""
manage('syncdb')
manage('migrate')
manage('create_groups')