-
Notifications
You must be signed in to change notification settings - Fork 1
/
fabfile.py
37 lines (28 loc) · 980 Bytes
/
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
import os
from fabric.api import *
from fabric.operations import put
from fabric.contrib.project import rsync_project
LOCAL_DIR = '/tmp/ifartradio'
REMOTE_DIR = '/www/ifartradio'
env.user = 'ifartradio'
env.hosts = ['66.175.213.211']
def update_requirements():
with cd(REMOTE_DIR), prefix('source bin/activate'):
run('pip install -r %s' % os.path.join(REMOTE_DIR, 'app', 'requirements.txt'))
def archive():
local('mkdir -p %s' % LOCAL_DIR)
local('git archive HEAD | tar -x -C %s' % LOCAL_DIR)
def push():
put(os.path.join(LOCAL_DIR, "supervisord.conf"), os.path.join(REMOTE_DIR, "supervisord.conf"))
for subdir in ['static/', 'app/']:
rsync_project(os.path.join(REMOTE_DIR, subdir), local_dir=os.path.join(LOCAL_DIR, subdir), delete=True, exclude="settings.py")
def restart():
with cd(REMOTE_DIR), prefix('source bin/activate'):
run("supervisorctl reload")
def cleanup():
local('rm -r %s' % LOCAL_DIR)
def deploy():
archive()
push()
# restart()
cleanup()