diff --git a/apollo-adminservice/src/main/scripts/startup.sh b/apollo-adminservice/src/main/scripts/startup.sh index 096faa69d4c1ef7490c502127368c13b31316764..521f357c1ab6225a0b77ce22f3c1bd684efbdabd 100644 --- a/apollo-adminservice/src/main/scripts/startup.sh +++ b/apollo-adminservice/src/main/scripts/startup.sh @@ -18,6 +18,24 @@ export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/ PATH_TO_JAR=$SERVICE_NAME".jar" SERVER_URL="http://localhost:$SERVER_PORT" +function checkPidAlive { + for i in `ls -t $SERVICE_NAME*.pid 2>/dev/null` + do + read pid < $i + + result=$(ps -p "$pid") + if [ "$?" -eq 0 ]; then + return 0 + else + printf "\npid - $pid just quit unexpectedly, please check logs under $LOG_DIR and /tmp for more information!\n" + exit 1; + fi + done + + printf "\nNo pid file found, startup may failed. Please check logs under $LOG_DIR and /tmp for more information!\n" + exit 1; +} + if [ "$(uname)" == "Darwin" ]; then windows="0" elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then @@ -77,7 +95,7 @@ then fi declare -i counter=0 -declare -i max_counter=16 # 16*5=80s +declare -i max_counter=48 # 48*5=240s declare -i total_time=0 printf "Waiting for server startup" @@ -86,6 +104,8 @@ do printf "." counter+=1 sleep 5 + + checkPidAlive done total_time=counter*5 diff --git a/apollo-configservice/src/main/scripts/startup.sh b/apollo-configservice/src/main/scripts/startup.sh index 46d22ff7ce77192b5c69c64eed9d319881f7860d..f28f51243b52399b5bc3d7fe4afa687fea44e96b 100644 --- a/apollo-configservice/src/main/scripts/startup.sh +++ b/apollo-configservice/src/main/scripts/startup.sh @@ -18,6 +18,24 @@ export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/ PATH_TO_JAR=$SERVICE_NAME".jar" SERVER_URL="http://localhost:$SERVER_PORT" +function checkPidAlive { + for i in `ls -t $SERVICE_NAME*.pid 2>/dev/null` + do + read pid < $i + + result=$(ps -p "$pid") + if [ "$?" -eq 0 ]; then + return 0 + else + printf "\npid - $pid just quit unexpectedly, please check logs under $LOG_DIR and /tmp for more information!\n" + exit 1; + fi + done + + printf "\nNo pid file found, startup may failed. Please check logs under $LOG_DIR and /tmp for more information!\n" + exit 1; +} + if [ "$(uname)" == "Darwin" ]; then windows="0" elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then @@ -77,7 +95,7 @@ then fi declare -i counter=0 -declare -i max_counter=16 # 16*5=80s +declare -i max_counter=48 # 48*5=240s declare -i total_time=0 printf "Waiting for server startup" @@ -86,6 +104,8 @@ do printf "." counter+=1 sleep 5 + + checkPidAlive done total_time=counter*5 diff --git a/apollo-portal/src/main/scripts/startup.sh b/apollo-portal/src/main/scripts/startup.sh index b6d83ad367e3e7c74a9cba836e5097950090ac1b..9477dbf51705cdb51e7020726d5ec803a506ad2a 100644 --- a/apollo-portal/src/main/scripts/startup.sh +++ b/apollo-portal/src/main/scripts/startup.sh @@ -18,6 +18,24 @@ export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/ PATH_TO_JAR=$SERVICE_NAME".jar" SERVER_URL="http://localhost:$SERVER_PORT" +function checkPidAlive { + for i in `ls -t $SERVICE_NAME*.pid 2>/dev/null` + do + read pid < $i + + result=$(ps -p "$pid") + if [ "$?" -eq 0 ]; then + return 0 + else + printf "\npid - $pid just quit unexpectedly, please check logs under $LOG_DIR and /tmp for more information!\n" + exit 1; + fi + done + + printf "\nNo pid file found, startup may failed. Please check logs under $LOG_DIR and /tmp for more information!\n" + exit 1; +} + if [ "$(uname)" == "Darwin" ]; then windows="0" elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then @@ -77,7 +95,7 @@ then fi declare -i counter=0 -declare -i max_counter=16 # 16*5=80s +declare -i max_counter=48 # 48*5=240s declare -i total_time=0 printf "Waiting for server startup" @@ -86,6 +104,8 @@ do printf "." counter+=1 sleep 5 + + checkPidAlive done total_time=counter*5