-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
54 lines (39 loc) · 1.18 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
#-*- coding: UTF-8 -*-
#################################################################
# > File: fabfile.py
# > Author: zhangminghua
# > Mail: zhangmh1993@163.com
# > Time: 2017-07-01 02:18:39 PM
#################################################################
import os
import sys
from fabric.api import local,lcd,cd,env,roles,run,execute,put
Main_Path = '~/github/pserver/'
project = 'project.tar.gz'
env.roledefs = {'server0': ['user@*.*.*.*:22',],
'server1': ['user@localhost:22',]}
@roles('server0')
def task0():
run('rm -rf %s' % Main_Path)
run('mkdir -p %s' % Main_Path)
put(Main_Path+project, Main_Path)
with cd(Main_Path):
run('tar -xzvf %s' % project)
run('rm %s' % project)
with cd(Main_Path+'ps/run/'):
run('sh -x ./run0.sh && sleep 1')
def task1():
with cd(Main_Path):
local('rm %s' % Main_Path+project)
with lcd(Main_Path+'ps/run/'):
local('sh -x ./run1.sh && sleep 1')
def prepare():
local('make clean')
local('make')
local('rm *.o')
with lcd(Main_Path):
local('tar -czvf %s ps/ ps-lite/' % project)
def deploy():
prepare()
execute(task0)
task1()