forked from jackluo2012/datacenter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
restart.sh
59 lines (53 loc) · 1.59 KB
/
restart.sh
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
#!/bin/bash
## author by jackluo
## Email [email protected]
## wechat 13228191831
getewayPath=$(pwd) #网关服务
userPath=$(pwd)/user/rpc #用户服务
commonPath=$(pwd)/common/rpc #公共服务
votesPath=$(pwd)/votes/rpc #投票服务
configPath=/etc/rpc.yaml #配置文件
geteWayCnf=/etc/datacenter-api.yaml
UserRpc=user-server #定义网关服务
CommonRpc=common-server #定义公共服务
VotesRpc=votes-server #定义投票服务
geteWayApi=datacenter-server #定义网关服务
RpcServer(){
mydir=$1
myserver=$2
mycnf=$3
cd ${mydir}
go build -o ${myserver} $mydir/rpc.go
kill -9 $(ps -ef|grep "${myserver}"|awk '{print $2}') >/dev/null 2>&1
nohup ${mydir}/${myserver} -f ${mydir}${mycnf} &
}
RpcServerPlus(){
mydir=$1/$2/rpc
myserver=${2}-server
mycnf=/etc/${2}.yaml
cd ${mydir}
go build -o ${myserver} $mydir/$2.go
kill -9 $(ps -ef|grep "${myserver}"|awk '{print $2}') >/dev/null 2>&1
nohup ${mydir}/${myserver} -f ${mydir}${mycnf} &
}
StartServer(){
mydir=$1
myserver=$2
mycnf=$3
cd ${mydir}
go build -o ${myserver} $mydir/datacenter.go
kill -9 $(ps -ef|grep "${myserver}"|awk '{print $2}') >/dev/null 2>&1
nohup ${mydir}/${myserver} -f ${mydir}${mycnf} &
}
#公共服务
RpcServer ${commonPath} ${CommonRpc} ${configPath}
#用户服务
RpcServer ${userPath} ${UserRpc} ${configPath}
#投票服务
RpcServer ${votesPath} ${VotesRpc} ${configPath}
#搜索服务
RpcServerPlus ${getewayPath} search
#问答抽奖服务
RpcServerPlus ${getewayPath} questions
#Api服务
StartServer ${getewayPath} ${geteWayApi} ${geteWayCnf}