forked from FederatedAI/FATE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.sh
101 lines (89 loc) · 2.18 KB
/
service.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
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
97
98
99
100
101
#!/bin/bash
#
# Copyright 2019 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
export PYTHONPATH=
log_dir="$(dirname $(dirname $(readlink -f "$0")))/logs"
venv=
module=fate_flow_server.py
getpid() {
pid=`lsof -i:9380 | awk 'NR==2{print $2}'`
}
mklogsdir() {
if [[ ! -d $log_dir ]]; then
mkdir -p $log_dir
fi
}
status() {
getpid
if [[ -n ${pid} ]]; then
echo "status:`ps aux | grep ${pid} | grep -v grep`"
else
echo "service not running"
fi
}
start() {
sleep 8
getpid
if [[ ${pid} == "" ]]; then
mklogsdir
source ${venv}/bin/activate
nohup python $(echo ${PYTHONPATH} | awk -F":" '{print $1}')/fate_flow/fate_flow_server.py >> "${log_dir}/console.log" 2>>"${log_dir}/error.log" &
sleep 6
getpid
if [[ -n ${pid} ]]; then
echo "service start sucessfully. pid: ${pid}"
else
echo "service start failed, please check ../logs/console.log and ../logs/error.log"
fi
else
echo "service already started. pid: ${pid}"
fi
}
stop() {
getpid
if [[ -n ${pid} ]]; then
echo "killing:
`ps aux | grep ${pid} | grep -v grep`"
kill -9 ${pid}
if [[ $? -eq 0 ]]; then
echo "killed"
else
echo "kill error"
fi
else
echo "service not running"
fi
}
case "$1" in
start)
start
status
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
status
;;
*)
echo "usage: $0 {start|stop|status|restart}"
exit -1
esac