-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfabfile.py
98 lines (72 loc) · 2.26 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
94
95
96
# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from __future__ import with_statement
from fabric.api import *
from contextlib import contextmanager as _contextmanager
@_contextmanager
def virtualenv():
with prefix(env.virtualenv_activate):
yield
env.hosts = ['176.58.125.166']
env.user = 'csik'
env.project_root = '/home/csik/public_python/rootio_telephony'
env.virtualenv_activate = 'source venv/bin/activate'
env.forward_agent = Truebranch = 'master'
def git_up(branch = "master"):
local("git add -p && git commit")
local("git push origin {0}".format(branch))
def git_update(branch = 'master'):
with cd(env.project_root):
stash_str = run("git stash")
run("git pull origin {0}".format(branch))
if stash_str.strip() != 'No local changes to save':
run("git stash pop")
def run_tel():
with cd(env.project_root):
with virtualenv():
run('screen -d -m python telephony_server.py; sleep 1')
def run_hack():
with cd('/home/csik/public_python/hack/deploy'):
with virtualenv():
run('screen -d -m python hack.py; sleep 1')
def kill_py():
run('killall python')
def restart_apache():
sudo("/etc/init.d/apache2 graceful")
def restart_cache():
sudo("/etc/init.d/memcached restart", pty=False)
def touch_wsgi():
# Touching the deploy.wsgi file will cause apache's mod_wsgi to
# reload all python modules having to restart apache.
with cd(env.project_root):
run("touch deploy/rootio_web.wsgi")
def update(full=False):
with cd(env.project_root):
git_update()
with virtualenv():
run("pip install -r requirements.txt")
run("python manage.py migrate up")
#todo: static files
touch_wsgi()
#restart_cache()
#restart_apache()
def deploy():
update()
def initdb():
local("python manage.py initdb")
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def runserver():
"""
Run local server, for debugging only.
Need to move up one directory, from deploy to see manage.py
"""
with lcd('..'):
reset()
initdb()
with virtualenv():
local("python manage.py run")