This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 373
/
fabfile.py
63 lines (46 loc) · 1.64 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
# coding: utf-8
from fabric.api import env, local, cd, run, sudo
from fabric.operations import put
env.use_ssh_config = True
env.keepalive = 60
def tarball():
"""Create tarball for june."""
local('make static')
local('python setup.py sdist --formats=gztar', capture=False)
def upload():
"""Upload tarball to the server."""
dist = local('python setup.py --fullname', capture=True).strip()
run('rm -f ~/tmp/june.tar.gz')
sudo('rm -fr ~/tmp/june')
run('mkdir -p ~/tmp/june')
put('dist/%s.tar.gz' % dist, '~/tmp/june.tar.gz')
with cd('~/tmp/june'):
run('tar xzf ~/tmp/june.tar.gz')
def install():
"""Install june package."""
dist = local('python setup.py --fullname', capture=True).strip()
with cd('~/tmp/june/%s' % dist):
sudo('/srv/venv/june/bin/pip install .')
def restart():
"""Restart remote server"""
run('supervisorctl pid june | xargs kill -HUP')
def bootstrap():
dist = local('python setup.py --fullname', capture=True).strip()
tarball()
upload()
# prepare
sudo('mkdir -p /var/log/june')
sudo('mkdir -p /srv/venv')
sudo('virtualenv /srv/venv/june')
sudo('mkdir -p /www/june/public/static')
install()
# install patch
sudo('/srv/venv/june/bin/pip install MySQL-python redis')
with cd('~/tmp/june/%s' % dist):
sudo('mv etc/nginx.conf /etc/nginx/conf.d/june.conf')
sudo('mv etc/supervisord.conf /etc/supervisor/conf.d/june.conf')
sudo('rm -fr /www/june/etc')
sudo('mv etc /www/june/')
sudo('rm -fr /www/june/public')
sudo('mv june/public /www/june/')
sudo('mv wsgi.py /www/june/')