-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
31 lines (24 loc) · 976 Bytes
/
fabfile.py
File metadata and controls
31 lines (24 loc) · 976 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
from fabric import api as fab
import os
from datetime import datetime
APP_DIR = "/srv/www/dashboard.qutm2m.com/"
DATE = datetime.utcnow().strftime("%Y%m%d%H%M%S")
try:
fab.env.hosts = os.environ['DEPLOY_HOSTS']
except KeyError:
print "Please set the env variable HOSTS as a comma separated list of hosts to deploy to."
try:
fab.env.user = os.environ['DEPLOY_USER']
except KeyError:
print "Please set DEPLOY_USER as a user who has write access to the src directory"
def reload_wsgi():
with fab.cd(APP_DIR):
fab.run('touch reload.wsgi')
def deploy():
with fab.cd(APP_DIR):
fab.run('wget https://github.com/qutm2m2014/dashboard/archive/master.tar.gz -O %s.tar.gz' % (DATE))
fab.run('mkdir app/%s' % (DATE))
fab.run('tar xvf %s.tar.gz -C app/%s --strip-components=1' % (DATE, DATE))
fab.run('ln -s %sapp/%s %sapp/current' % (APP_DIR, DATE, APP_DIR))
fab.run('rm %s.tar.gz' % (DATE))
reload_wsgi()