-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
stop-all.sh
194 lines (152 loc) · 3.85 KB
/
stop-all.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/env bash
#
# Copyright 2019 WeBank
#
# 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.
#
# Stop all linkis applications
info="We will stop all linkis applications, it will take some time, please wait"
echo ${info}
#Actively load user env
source /etc/profile
source ~/.bash_profile
workDir=`dirname "${BASH_SOURCE-$0}"`
workDir=`cd "$workDir"; pwd`
CONF_DIR="${workDir}"/../conf
CONF_FILE=${CONF_DIR}/config.sh
function isSuccess(){
if [ $? -ne 0 ]; then
echo "ERROR: " + $1
exit 1
else
echo "INFO:" + $1
fi
}
local_host="`hostname --fqdn`"
ipaddr=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
function isLocal(){
if [ "$1" == "127.0.0.1" ];then
return 0
elif [ $1 == "localhost" ]; then
return 0
elif [ $1 == $local_host ]; then
return 0
elif [ $1 == $ipaddr ]; then
return 0
fi
return 1
}
function executeCMD(){
isLocal $1
flag=$?
echo "Is local "$flag
if [ $flag == "0" ];then
eval $2
else
ssh -p $SSH_PORT $1 $2
fi
}
#if there is no LINKIS_INSTALL_HOME,we need to source config again
if [ -z ${LINKIS_INSTALL_HOME} ];then
echo "Warning: LINKIS_INSTALL_HOME does not exist, we will source config"
if [ ! -f "${CONF_FILE}" ];then
echo "Error: can not find config file, stop applications failed"
exit 1
else
source ${CONF_FILE}
fi
fi
APP_PREFIX="linkis-"
function stopApp(){
echo "<-------------------------------->"
echo "Begin to stop $SERVER_NAME"
SERVER_PATH=${APP_PREFIX}${SERVER_NAME}
SERVER_BIN=${LINKIS_INSTALL_HOME}/${SERVER_PATH}/bin
SERVER_LOCAL_STOP_CMD="sh ${SERVER_BIN}/stop-${SERVER_NAME}.sh"
SERVER_REMOTE_STOP_CMD="source /etc/profile;source ~/.bash_profile;cd ${SERVER_BIN}; sh stop-${SERVER_NAME}.sh "
if test -z "$SERVER_IP"
then
SERVER_IP=$local_host
fi
if ! executeCMD $SERVER_IP "test -e $SERVER_BIN"; then
echo "$SERVER_NAME is not installed,the stopApp steps will be skipped"
return
fi
isLocal $SERVER_IP
flag=$?
echo "Is local "$flag
if [ $flag == "0" ];then
eval $SERVER_LOCAL_STOP_CMD
else
ssh -p $SSH_PORT $SERVER_IP $SERVER_REMOTE_STOP_CMD
fi
echo "<-------------------------------->"
sleep 3
}
#eureka
SERVER_NAME="eureka"
APP_PREFIX=""
SERVER_IP=$EUREKA_INSTALL_IP
stopApp
APP_PREFIX="linkis-"
#gateway
SERVER_NAME="gateway"
SERVER_IP=$GATEWAY_INSTALL_IP
stopApp
#publicservice
SERVER_NAME="publicservice"
SERVER_IP=$PUBLICSERVICE_INSTALL_IP
stopApp
#bml
SERVER_NAME="bml"
SERVER_IP=$BML_INSTALL_IP
stopApp
#metadata
SERVER_NAME="metadata"
SERVER_IP=$METADATA_INSTALL_IP
stopApp
APP_PREFIX="linkis-ujes-"
#python-entrance
SERVER_NAME="python-entrance"
SERVER_IP=$PYTHON_INSTALL_IP
stopApp
#python-enginemanager
SERVER_NAME="python-enginemanager"
SERVER_IP=$PYTHON_INSTALL_IP
stopApp
#spark-entrance
SERVER_NAME="spark-entrance"
SERVER_IP=$SPARK_INSTALL_IP
stopApp
#spark-enginemanager
SERVER_NAME="spark-enginemanager"
SERVER_IP=$SPARK_INSTALL_IP
stopApp
#hive-entrance
SERVER_NAME="hive-entrance"
SERVER_IP=$HIVE_INSTALL_IP
stopApp
#hive-enginemanager
SERVER_NAME="hive-enginemanager"
SERVER_IP=$HIVE_INSTALL_IP
stopApp
#JDBCEntrance
SERVER_NAME="jdbc-entrance"
SERVER_IP=$JDBC_INSTALL_IP
stopApp
APP_PREFIX="linkis-"
#resourcemanager
SERVER_NAME="resourcemanager"
SERVER_IP=$RESOURCEMANAGER_INSTALL_IP
stopApp
echo "stop-all shell script executed completely"