Skip to content

Commit

Permalink
Add the content to check whether all services start normally in the s…
Browse files Browse the repository at this point in the history
…tart-all.sh script

Closes #195
  • Loading branch information
peacewong committed Dec 14, 2019
1 parent 9a64f81 commit b62502d
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 48 deletions.
72 changes: 72 additions & 0 deletions bin/checkServices.sh
@@ -0,0 +1,72 @@
#
# 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.
#
#!/bin/sh
source ~/.bash_profile

shellDir=`dirname $0`
workDir=`cd ${shellDir}/..;pwd`

##load config
source ${workDir}/conf/config.sh

MICRO_SERVICE_NAME=$1
MICRO_SERVICE_IP=$2
MICRO_SERVICE_PORT=$3

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

}

echo "Start to Check if your microservice:$MICRO_SERVICE_NAME is normal via telnet"

result=`echo -e "\n" | telnet $MICRO_SERVICE_IP $MICRO_SERVICE_PORT 2>/dev/null | grep Connected | wc -l`
if [ $result -eq 1 ]; then
echo "$MICRO_SERVICE_NAME is ok."
else
echo "ERROR your $MICRO_SERVICE_NAME microservice is not start successful !!! ERROR logs as follows :"
echo "PLEAESE CHECK DETAIL LOG,LOCATION:$LINKIS_INSTALL_HOME/$MICRO_SERVICE_NAME/logs/linkis.out"
echo '<---------------------------------------------------->'
executeCMD $MICRO_SERVICE_IP "tail -n 50 $LINKIS_INSTALL_HOME/$MICRO_SERVICE_NAME/logs/*.out"
echo '<---------------------------------------------------->'
echo "PLEAESE CHECK DETAIL LOG,LOCATION:$LINKIS_INSTALL_HOME/$MICRO_SERVICE_NAME/logs/linkis.out"
exit 1
fi

170 changes: 143 additions & 27 deletions bin/start-all.sh
Expand Up @@ -22,6 +22,7 @@ info="We will start 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}"`
Expand All @@ -33,18 +34,45 @@ CONF_FILE=${CONF_DIR}/config.sh

function isSuccess(){
if [ $? -ne 0 ]; then
echo "ERROR: " + $1
echo "Failed to " + $1
exit 1
else
echo "INFO:" + $1
echo "Succeed to" + $1
fi
}

sudo yum -y install dos2unix > /dev/null 2>&1

sudo yum -y install dos2unix > /dev/null 2>&1

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"
Expand All @@ -62,11 +90,20 @@ echo "<-------------------------------->"
echo "Begin to start $SERVER_NAME"
SERVER_PATH=${APP_PREFIX}${SERVER_NAME}
SERVER_BIN=${LINKIS_INSTALL_HOME}/${SERVER_PATH}/bin
SERVER_START_CMD="source ~/.bash_profile;cd ${SERVER_BIN}; dos2unix ./* > /dev/null 2>&1; dos2unix ../conf/* > /dev/null 2>&1; sh start-${SERVER_NAME}.sh > /dev/null 2>&1"
if [ -n "${SERVER_IP}" ];then
ssh -p $SSH_PORT ${SERVER_IP} "${SERVER_START_CMD}"
SERVER_LOCAL_START_CMD="dos2unix ${SERVER_BIN}/* > /dev/null 2>&1; dos2unix ${SERVER_BIN}/../conf/* > /dev/null 2>&1; sh ${SERVER_BIN}/start-${SERVER_NAME}.sh"
SERVER_REMOTE_START_CMD="source /etc/profile;source ~/.bash_profile;cd ${SERVER_BIN}; dos2unix ./* > /dev/null 2>&1; dos2unix ../conf/* > /dev/null 2>&1; sh start-${SERVER_NAME}.sh > /dev/null 2>&1"
if test -z "$SERVER_IP"
then
SERVER_IP=$local_host
fi

isLocal $SERVER_IP
flag=$?
echo "Is local "$flag
if [ $flag == "0" ];then
eval $SERVER_LOCAL_START_CMD
else
ssh -p $SSH_PORT ${local_host} "${SERVER_START_CMD}"
ssh -p $SSH_PORT $SERVER_IP $SERVER_REMOTE_START_CMD
fi
isSuccess "End to start $SERVER_NAME"
echo "<-------------------------------->"
Expand All @@ -92,17 +129,17 @@ SERVER_NAME="publicservice"
SERVER_IP=$PUBLICSERVICE_INSTALL_IP
startApp

#bml
SERVER_NAME="bml"
SERVER_IP=$BML_INSTALL_IP
startApp


#metadata
SERVER_NAME="metadata"
SERVER_IP=$METADATA_INSTALL_IP
startApp

#bml
SERVER_NAME="bml"
SERVER_IP=$BML_INSTALL_IP
startApp

#resourcemanager
SERVER_NAME="resourcemanager"
SERVER_IP=$RESOURCEMANAGER_INSTALL_IP
Expand All @@ -111,6 +148,17 @@ echo "sleep 15 seconds to wait RM to be ready"
sleep 15

APP_PREFIX="linkis-ujes-"

#python-entrance
SERVER_NAME="python-entrance"
SERVER_IP=$PYTHON_INSTALL_IP
startApp

#python-enginemanager
SERVER_NAME="python-enginemanager"
SERVER_IP=$PYTHON_INSTALL_IP
startApp

#spark-entrance
SERVER_NAME="spark-entrance"
SERVER_IP=$SPARK_INSTALL_IP
Expand All @@ -132,27 +180,95 @@ SERVER_NAME="hive-enginemanager"
SERVER_IP=$HIVE_INSTALL_IP
startApp

#python-entrance
SERVER_NAME="python-entrance"
SERVER_IP=$PYTHON_INSTALL_IP

#JDBCEntrance
SERVER_NAME="jdbc-entrance"
SERVER_IP=$JDBC_INSTALL_IP
startApp

#python-enginemanager
SERVER_NAME="python-enginemanager"

echo "start-all shell script executed completely"

echo "Start to check all dss microservice"

function checkServer(){
echo "<-------------------------------->"
echo "Begin to check $SERVER_NAME"
if test -z "$SERVER_IP"
then
SERVER_IP=$local_host
fi
sh $workDir/checkServices.sh $SERVER_NAME $SERVER_IP $SERVER_PORT
isSuccess "start $SERVER_NAME "
echo "<-------------------------------->"
sleep 3
}
SERVER_NAME="eureka"
SERVER_IP=$EUREKA_INSTALL_IP
SERVER_PORT=$EUREKA_PORT
checkServer

APP_PREFIX="linkis-"
SERVER_NAME=$APP_PREFIX"gateway"
SERVER_IP=$GATEWAY_INSTALL_IP
SERVER_PORT=$GATEWAY_PORT
checkServer

SERVER_NAME=$APP_PREFIX"publicservice"
SERVER_IP=$PUBLICSERVICE_INSTALL_IP
SERVER_PORT=$PUBLICSERVICE_PORT
checkServer

SERVER_NAME=$APP_PREFIX"metadata"
SERVER_IP=$METADATA_INSTALL_IP
SERVER_PORT=$METADATA_PORT
checkServer

SERVER_NAME=$APP_PREFIX"resourcemanager"
SERVER_IP=$RESOURCEMANAGER_INSTALL_IP
SERVER_PORT=$RESOURCEMANAGER_PORT
checkServer


SERVER_NAME=$APP_PREFIX"bml"
SERVER_IP=$BML_INSTALL_IP
SERVER_PORT=$BML_PORT
checkServer

APP_PREFIX="linkis-ujes-"
SERVER_NAME=$APP_PREFIX"python-entrance"
SERVER_IP=$PYTHON_INSTALL_IP
startApp
SERVER_PORT=$PYTHON_ENTRANCE_PORT
checkServer

SERVER_NAME=$APP_PREFIX"python-enginemanager"
SERVER_IP=$PYTHON_INSTALL_IP
SERVER_PORT=$PYTHON_EM_PORT
checkServer

SERVER_NAME=$APP_PREFIX"spark-entrance"
SERVER_IP=$SPARK_INSTALL_IP
SERVER_PORT=$SPARK_ENTRANCE_PORT
checkServer

#JDBCEntrance
SERVER_NAME="jdbc-entrance"
SERVER_IP=$JDBC_INSTALL_IP
startApp
SERVER_NAME=$APP_PREFIX"spark-enginemanager"
SERVER_IP=$SPARK_INSTALL_IP
SERVER_PORT=$SPARK_EM_PORT
checkServer

SERVER_NAME=$APP_PREFIX"hive-enginemanager"
SERVER_IP=$HIVE_INSTALL_IP
SERVER_PORT=$HIVE_EM_PORT
checkServer

#mlsql-entrance
SERVER_NAME="mlsql-entrance"
SERVER_IP=$MLSQL_INSTALL_IP
startApp
SERVER_NAME=$APP_PREFIX"hive-entrance"
SERVER_IP=$HIVE_INSTALL_IP
SERVER_PORT=$HIVE_ENTRANCE_PORT
checkServer

echo "start-all shell script executed completely"
SERVER_NAME=$APP_PREFIX"jdbc-entrance"
SERVER_IP=$JDBC_INSTALL_IP
SERVER_PORT=$JDBC_ENTRANCE_PORT
checkServer

echo "Linkis started successfully"

0 comments on commit b62502d

Please sign in to comment.