Skip to content

Commit

Permalink
Merge pull request apolloconfig#564 from nobodyiam/startup-log
Browse files Browse the repository at this point in the history
output start up log to console
  • Loading branch information
lepdou authored Mar 9, 2017
2 parents e28ff8f + 148a375 commit 573b118
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
13 changes: 6 additions & 7 deletions apollo-adminservice/src/main/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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"
STARTUP_LOG=$LOG_DIR"/startup.log"

if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
export JAVA_HOME=/usr/java/latest/
Expand Down Expand Up @@ -47,7 +46,7 @@ if [[ -f $SERVICE_NAME".jar" ]]; then
rm -rf $SERVICE_NAME".jar"
fi

printf "$(date) ==== Starting ==== \n" > $STARTUP_LOG
printf "$(date) ==== Starting ==== \n"

ln $PATH_TO_JAR $SERVICE_NAME".jar"
chmod a+x $SERVICE_NAME".jar"
Expand All @@ -57,18 +56,18 @@ rc=$?;

if [[ $rc != 0 ]];
then
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc" >> $STARTUP_LOG
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc"
exit $rc;
fi

declare -i counter=0
declare -i max_counter=16 # 16*5=80s
declare -i total_time=0

printf "Waiting for server startup" >> $STARTUP_LOG
printf "Waiting for server startup"
until [[ (( counter -ge max_counter )) || "$(curl -X GET --silent --connect-timeout 1 --max-time 2 --head $SERVER_URL | grep "Coyote")" != "" ]];
do
printf "." >> $STARTUP_LOG
printf "."
counter+=1
sleep 5
done
Expand All @@ -77,10 +76,10 @@ total_time=counter*5

if [[ (( counter -ge max_counter )) ]];
then
printf "\n$(date) Server failed to start in $total_time seconds!\n" >> $STARTUP_LOG
printf "\n$(date) Server failed to start in $total_time seconds!\n"
exit 1;
fi

printf "\n$(date) Server started in $total_time seconds!\n" >> $STARTUP_LOG
printf "\n$(date) Server started in $total_time seconds!\n"

exit 0;
13 changes: 6 additions & 7 deletions apollo-configservice/src/main/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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"
STARTUP_LOG=$LOG_DIR"/startup.log"

if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
export JAVA_HOME=/usr/java/latest/
Expand Down Expand Up @@ -47,7 +46,7 @@ if [[ -f $SERVICE_NAME".jar" ]]; then
rm -rf $SERVICE_NAME".jar"
fi

printf "$(date) ==== Starting ==== \n" > $STARTUP_LOG
printf "$(date) ==== Starting ==== \n"

ln $PATH_TO_JAR $SERVICE_NAME".jar"
chmod a+x $SERVICE_NAME".jar"
Expand All @@ -57,18 +56,18 @@ rc=$?;

if [[ $rc != 0 ]];
then
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc" >> $STARTUP_LOG
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc"
exit $rc;
fi

declare -i counter=0
declare -i max_counter=16 # 16*5=80s
declare -i total_time=0

printf "Waiting for server startup" >> $STARTUP_LOG
printf "Waiting for server startup"
until [[ (( counter -ge max_counter )) || "$(curl -X GET --silent --connect-timeout 1 --max-time 2 --head $SERVER_URL | grep "Coyote")" != "" ]];
do
printf "." >> $STARTUP_LOG
printf "."
counter+=1
sleep 5
done
Expand All @@ -77,10 +76,10 @@ total_time=counter*5

if [[ (( counter -ge max_counter )) ]];
then
printf "\n$(date) Server failed to start in $total_time seconds!\n" >> $STARTUP_LOG
printf "\n$(date) Server failed to start in $total_time seconds!\n"
exit 1;
fi

printf "\n$(date) Server started in $total_time seconds!\n" >> $STARTUP_LOG
printf "\n$(date) Server started in $total_time seconds!\n"

exit 0;
13 changes: 6 additions & 7 deletions apollo-portal/src/main/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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"
STARTUP_LOG=$LOG_DIR"/startup.log"

if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
export JAVA_HOME=/usr/java/latest/
Expand Down Expand Up @@ -47,7 +46,7 @@ if [[ -f $SERVICE_NAME".jar" ]]; then
rm -rf $SERVICE_NAME".jar"
fi

printf "$(date) ==== Starting ==== \n" > $STARTUP_LOG
printf "$(date) ==== Starting ==== \n"

ln $PATH_TO_JAR $SERVICE_NAME".jar"
chmod a+x $SERVICE_NAME".jar"
Expand All @@ -57,18 +56,18 @@ rc=$?;

if [[ $rc != 0 ]];
then
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc" >> $STARTUP_LOG
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc"
exit $rc;
fi

declare -i counter=0
declare -i max_counter=16 # 16*5=80s
declare -i total_time=0

printf "Waiting for server startup" >> $STARTUP_LOG
printf "Waiting for server startup"
until [[ (( counter -ge max_counter )) || "$(curl -X GET --silent --connect-timeout 1 --max-time 2 --head $SERVER_URL | grep "Coyote")" != "" ]];
do
printf "." >> $STARTUP_LOG
printf "."
counter+=1
sleep 5
done
Expand All @@ -77,10 +76,10 @@ total_time=counter*5

if [[ (( counter -ge max_counter )) ]];
then
printf "\n$(date) Server failed to start in $total_time seconds!\n" >> $STARTUP_LOG
printf "\n$(date) Server failed to start in $total_time seconds!\n"
exit 1;
fi

printf "\n$(date) Server started in $total_time seconds!\n" >> $STARTUP_LOG
printf "\n$(date) Server started in $total_time seconds!\n"

exit 0;

0 comments on commit 573b118

Please sign in to comment.