-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
93 lines (72 loc) · 2.68 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
89
90
91
92
93
from __future__ import with_statement
from fabric.api import *
def staging():
projectname = 'isimip'
basepath = '/srv/isimip.brueck.io/%s'
env.hosts = ['{0}@{0}.brueck.io'.format(projectname)]
env.path = basepath % projectname
env.virtualenv_path = basepath % (projectname+'env')
env.backup_path = basepath % 'backups'
env.push_branch = 'staging'
env.push_remote = 'origin'
env.reload_cmd = 'supervisorctl restart {0}'.format(projectname)
env.db_name = projectname
env.db_username = projectname
env.after_deploy_url = 'http://%s.brueck.io' % projectname
def production():
projectname = 'isimip'
basepath = '/webservice/isimip.org/%s'
env.hosts = ['[email protected]']
env.path = basepath % 'htdocs'
env.virtualenv_path = basepath % 'virtualenv'
env.push_branch = 'master'
env.push_remote = 'origin'
env.db_name = projectname
env.db_username = projectname
env.after_deploy_url = 'http://isimip.org'
env.reload_cmd = 'sudo supervisorctl restart isimip'
def reload_webserver():
run("%(reload_cmd)s" % env)
def migrate():
with prefix("source %(virtualenv_path)s/bin/activate" % env):
run("%(path)s/manage.py migrate --settings=config.settings.production" % env)
def ping():
run("echo %(after_deploy_url)s returned: \>\>\> $(curl --write-out %%{http_code} --silent --output /dev/null %(after_deploy_url)s)" % env)
def deploy():
with cd(env.path):
run("git pull %(push_remote)s %(push_branch)s" % env)
with prefix("source %(virtualenv_path)s/bin/activate" % env):
# run("pip install -r requirements/production.txt")
run("./manage.py collectstatic --noinput --settings=config.settings.production")
migrate()
reload_webserver()
ping()
def soft_deploy():
with cd(env.path):
run("git pull %(push_remote)s %(push_branch)s" % env)
reload_webserver()
ping()
def pip():
with cd(env.path):
run("git pull %(push_remote)s %(push_branch)s" % env)
with prefix("source %(virtualenv_path)s/bin/activate" % env):
run("pip install -Ur requirements/production.txt")
reload_webserver()
#
# def init_fixtures():
# with virtualenv(env.virtualenv_path):
# run("%(path)s/manage.py loaddata init.json" % env)
#
#
# def update():
# ''' Only deploy and reload modules from git, do no installing or migrating'''
# with cd(env.path):
# run("git pull %(push_remote)s %(push_branch)s" % env)
#
# reload_webserver()
#
#
# def backup():
# with cd(env.backup_path):
# run("pg_dump -U %(db_username)s %(db_name)s > %(db_name)s_backup_$(date +%%F-%%T).sql" % env)
# run("ls -lt")