-
Notifications
You must be signed in to change notification settings - Fork 1
/
fabfile.py
50 lines (37 loc) · 1.11 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
from fabric.api import *
from fabric.operations import run
from fabric.context_managers import cd
from fabric.api import env, prefix
from fabric.colors import green
HOST_NAME = ['bankcenter.in']
USER = "bankcenter_in"
REPO_PATH = "~/bankcenter/bank_center"
env.hosts = HOST_NAME
env.user = USER
env.directory = REPO_PATH
env.activate = 'source ~/bankcenter/bin/activate'
def restart():
print(green("Restarting...\n"))
run("gunicorn_django -c ~/confs/gunicorn/gunicorn_cfg.py")
print(green("Restarted\n"))
def kill_process():
print(green("Killing gunicorn process...\n"))
run("kill `cat ~/confs/gunicorn/pid.txt`")
print("Killed gunicorn process")
def syncdb():
print(green("syncdb is running...\n"))
run("python manage.py syncdb")
def migrate():
print(green("Migrating database...\n"))
run("python manage.py migrate")
def pull():
print(green("Pulling the latest code...\n"))
run("git pull")
def deploy():
with cd(env.directory):
with prefix(env.activate):
pull()
migrate()
syncdb()
kill_process()
restart()