-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
94 lines (56 loc) · 1.9 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
# -*- coding: utf-8 -*-
from __future__ import with_statement
from fabric.api import *
#from fabric.contrib.console import confirm
'''
henüz yapmadıysan: pip install fabric
fab prepare => git commit -a -m '~' && git push
fab prepare:m="mesaj kaygisi" => git commit -a -m 'mesaj kaygisi' && git push
fab prepare:-A => git add -A && git commit -a && git push
fab prepare:-A, mesaj_metni => git add -A && git commit -a -m 'mesaj_metni' && git push
kısacası prepare: den sonra ne yazarsan "git add" komutuna ekleniyor, hiçbirşey yazmazsan git add komutu çalıştırılmıyor.
kullanacağımız diğer komut "fab deploy"
fab deploy
ya da eğer db göçü yapılacaksa:
fab deploy:1
'''
env.hosts = ['[email protected]']
#site_list = ['weblonya',]
deploy_dir = '/home/cnvar/forum-server'
def prepare(add_this='-A', m='~'):
# local("./manage.py test my_app")
if add_this:
local("git add %s" % add_this)
local("git commit -a -m '%s'" % m)
local("git push")
def full(goc=''):
if goc == '2':
localmigrate()
prepare()
deploy(goc)
def pull():
prepare()
justpull()
def localmigrate(what='umatik'):
local("./manage.py schemamigration --auto %s" % what)
local("./manage.py migrate --all")
def wsync():
local("rsync -rzh --progress --exclude-from=exclude.list client/www/* "
"[email protected]:/home/cnvar/forum-server/client/www/")
def deploy(migrate=False):
local("git push")
with cd(deploy_dir):
run("git fetch --all")
run("git reset --hard origin/master")
if migrate:
remote_migrate()
restart_sites()
def justpull():
with cd(deploy_dir):
run("git fetch --all")
run("git reset --hard origin/master")
def restart_sites():
run("supervisorctl restart forum-server")
def remote_migrate():
with cd(deploy_dir):
run("./manage.py migrate --all")