This repository was archived by the owner on Oct 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfabfile.py
More file actions
100 lines (72 loc) · 2.89 KB
/
fabfile.py
File metadata and controls
100 lines (72 loc) · 2.89 KB
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
94
95
96
97
98
99
100
from fabric.api import *
vars = {
'app_dir': '/usr/local/apps/madrona-devops/madrona',
'venv': '/usr/local/venv/madrona'
}
env.forward_agent = True
env.key_filename = '~/.vagrant.d/insecure_private_key'
def dev():
""" Use development server settings """
servers = ['vagrant@127.0.0.1:2222']
env.hosts = servers
return servers
def prod():
""" Use production server settings """
servers = []
env.hosts = servers
return servers
def test():
""" Use test server settings """
servers = []
env.hosts = servers
return servers
def all():
""" Use all servers """
env.hosts = dev() + prod() + test()
def _install_requirements():
run('cd %(app_dir)s && %(venv)s/bin/pip install -r ../requirements.txt' % vars)
def _install_django():
run('cd %(app_dir)s && %(venv)s/bin/python manage.py syncdb --noinput && \
%(venv)s/bin/python manage.py migrate --noinput && \
%(venv)s/bin/python manage.py install_media -a && \
%(venv)s/bin/python manage.py enable_sharing --all && \
%(venv)s/bin/python manage.py install_cleangeometry' % vars)
def create_superuser():
""" Create the django superuser (interactive!) """
run('cd %(app_dir)s && %(venv)s/bin/python manage.py createsuperuser' % vars)
def import_data():
""" Fetches and installs data fixtures (WARNING: 5+GB of data; hence not checking fixtures into the repo) """
run('cd %(app_dir)s && %(venv)s/bin/python manage.py import_data' % vars)
def init():
""" Initialize the forest planner application """
_install_requirements()
_install_django()
_install_starspan()
def runserver():
""" Run the django dev server on port 8000 """
run('cd %(app_dir)s && %(venv)s/bin/python manage.py runserver 0.0.0.0:8000' % vars)
def update():
""" Sync with master git repo """
run('cd %(app_dir)s && git fetch && git merge origin/master' % vars)
init()
def _install_starspan():
run('mkdir -p ~/src && cd ~/src && \
if [ ! -d "starspan" ]; then git clone git://github.com/Ecotrust/starspan.git; fi && \
cd starspan && \
if [ ! `which starspan` ]; then ./configure && make && sudo make install; fi')
# TODO
# figure out line b/t puppet and fabric duties
# run test suite
# run selenium
# a "bootstrap_puppet" command to ssh into an arbitrary box, transfer files, set things up and run puppet
# .. basically a vagrant up for non virtualbox servers
# TODO celeryd under supervisor control
"""
(lot)vagrant@precise32:/usr/local/apps/land_owner_tools$ sudo supervisorctl reload
Restarted supervisord
(lot)vagrant@precise32:/usr/local/apps/land_owner_tools$ sudo supervisorctl status
celeryd STARTING
(lot)vagrant@precise32:/usr/local/apps/land_owner_tools$ sudo supervisorctl restart celeryd
celeryd: stopped
celeryd: started
"""