forked from lexzheng/walis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
96 lines (75 loc) · 1.82 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
92
93
94
95
96
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
import os
from fabric.api import (
env,
execute,
local,
task,
hosts,
)
env.use_ssh_config = True
env.keepalive = 60
DEPLOYMENT_PARAMS = {
"repo": "walis",
"remote_user": "www-data",
"local_dir": os.path.dirname(os.path.realpath(__file__)),
"remote_dir": "/srv/walis",
"remote_exclude": "rsync_exclude.txt",
"requirements": "requirements.txt",
"require_install": True,
"virtualenv": "/srv/virtualenvs/walisenv",
"services": [
"walis:",
"walis_thrift:",
# "beanstalk:",
# "scheduler:",
],
}
@task
def dev(*args):
""" Deploy dev env.
:param args: host names
:return:
"""
if not args:
print('Tips: \n1. `fab dev:hostname1,hostname2,hostname3`'
'\n2. `fab dev:all`')
return
if args[0] == 'all':
env.hosts = ['t-walis-1',
't-walis-2',
't-walis-3',
't-walis-4',
't-walis-test', ]
else:
env.hosts = args
execute(_walis_deploy)
@task
@hosts(['xg-ppe-walle',])
def ppe_deploy():
execute(_walis_deploy)
@task
@hosts(['d048-app-11', 'd048-app-12'])
def d_deploy():
execute(_walis_deploy)
@task
@hosts(['p-web-6'])
def p_deploy():
execute(_walis_deploy)
@task
def tag():
local("git checkout master")
local("git reset --hard origin/master")
local("git merge develop")
local("git push")
tag = "v{0}".format(datetime.datetime.now().strftime("%Y%m%d%H%M"))
local("git tag -f {0}".format(tag))
local("git push --tags")
local("git checkout develop")
@task
def _walis_deploy():
import deployele
# local("git fetch origin --prune --tags")
execute(deployele.python_deploy, **DEPLOYMENT_PARAMS)