-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
56 lines (46 loc) · 1.83 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
from fabric.api import *
def prod():
env.user = 'root'
env.hosts = ['178.79.138.225']
env.site_path = '/srv/www/tomusher-blog'
env.repo_path = '{0}/current'.format(env.site_path)
env.source_path = '{0}/current/source'.format(env.repo_path)
env.activate = 'source /srv/www/tomusher-blog/env/bin/activate'
env.data_bag_key_path = '/Users/tomusher/.keys/data_bag_key'
def vagrant():
env.user = 'root'
env.hosts = ['127.0.0.1:2222']
env.site_path = '/srv/www/tomusher-blog'
env.repo_path = '{0}/current'.format(env.site_path)
env.source_path = '{0}/current/source'.format(env.repo_path)
env.activate = 'source /srv/www/tomusher-blog/env/bin/activate'
env.data_bag_key_path = '/Users/tomusher/.keys/data_bag_key'
def bootstrap():
with lcd('deploy'):
local('librarian-chef install')
local('fix node:{0} deploy_chef'.format(env.host))
def cook():
with lcd('deploy'):
put(env.data_bag_key_path, '/tmp/encrypted_data_bag_secret')
local('fix node:{0} role:tomusher-blog'.format(env.host))
def reload():
run("supervisorctl restart tomusher-blog")
def autosync():
"Automatically synchronise changes. For testing only."
import watchdog
from watchdog.observers import Observer
import time
import os
class RsyncEventHandler(watchdog.events.PatternMatchingEventHandler):
def on_any_event(self, event):
run("/srv/www/tomusher-blog/env/bin/python /srv/www/tomusher-blog/current/source/manage.py collectstatic --noinput")
reload()
observer = Observer()
observer.schedule(RsyncEventHandler(patterns=["*.css","*.js","*.py","*.html"]), path=os.getcwd(), recursive=True)
observer.start()
try:
while True:
time.sleep(100)
except KeyboardInterrupt:
observer.stop()
observer.join()