forked from Z-Tool/ztool-backhend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
executable file
·50 lines (37 loc) · 1.58 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
from fabric.api import run, roles, cd
from fabric.context_managers import env
from fabric.contrib.project import rsync_project
code_dir = '/jalpc'
local_dir = '/Users/jack/Dropbox/Jack/jalpc-flask'
exclude = ('.DS_Store', '*pyc', '.git', '.idea', '*sqlite3', 'migrations')
env.roledefs = {
'vps': ['[email protected]']
}
@roles('vps')
def install():
run('apt-get update && apt-get install -y python-pip python-dev uwsgi-plugin-python nginx')
rsync_project(local_dir='requirements.txt', remote_dir=code_dir)
with cd(code_dir):
run('pip2.7 install -r requirements.txt')
run('mv jalpc.conf /etc/nginx/sites-enabled/ && rm -f /etc/nginx/sites-enabled/default && service nginx reload')
run('mkdir /home/www && chown -R www-data. /home/www')
run('/usr/bin/uwsgi jalpc.ini')
@roles('vps')
def pip():
rsync_project(local_dir='requirements.txt', remote_dir=code_dir)
with cd(code_dir):
run('pip2.7 install -r requirements.txt')
@roles('vps')
def deploy():
rsync_project(local_dir='.', remote_dir=code_dir, exclude=exclude)
run('cp -a /jalpc/app/static /jalpc/static && source ~/.jalpc-env && uwsgi --reload /run/uwsgi.pid')
@roles('vps')
def backup():
rsync_project(local_dir=local_dir, remote_dir=os.path.join(code_dir, 'migrations/versions'), upload=False, exclude=exclude)
@roles('vps')
def upload():
rsync_project(local_dir=os.path.join(local_dir, 'versions'), remote_dir=os.path.join(code_dir, 'migrations'), exclude=exclude)