Skip to content

Commit 573b118

Browse files
authored
Merge pull request apolloconfig#564 from nobodyiam/startup-log
output start up log to console
2 parents e28ff8f + 148a375 commit 573b118

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

apollo-adminservice/src/main/scripts/startup.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/
1414

1515
PATH_TO_JAR=$SERVICE_NAME".jar"
1616
SERVER_URL="http://localhost:$SERVER_PORT"
17-
STARTUP_LOG=$LOG_DIR"/startup.log"
1817

1918
if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
2019
export JAVA_HOME=/usr/java/latest/
@@ -47,7 +46,7 @@ if [[ -f $SERVICE_NAME".jar" ]]; then
4746
rm -rf $SERVICE_NAME".jar"
4847
fi
4948

50-
printf "$(date) ==== Starting ==== \n" > $STARTUP_LOG
49+
printf "$(date) ==== Starting ==== \n"
5150

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

5857
if [[ $rc != 0 ]];
5958
then
60-
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc" >> $STARTUP_LOG
59+
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc"
6160
exit $rc;
6261
fi
6362

6463
declare -i counter=0
6564
declare -i max_counter=16 # 16*5=80s
6665
declare -i total_time=0
6766

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

7877
if [[ (( counter -ge max_counter )) ]];
7978
then
80-
printf "\n$(date) Server failed to start in $total_time seconds!\n" >> $STARTUP_LOG
79+
printf "\n$(date) Server failed to start in $total_time seconds!\n"
8180
exit 1;
8281
fi
8382

84-
printf "\n$(date) Server started in $total_time seconds!\n" >> $STARTUP_LOG
83+
printf "\n$(date) Server started in $total_time seconds!\n"
8584

8685
exit 0;

apollo-configservice/src/main/scripts/startup.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/
1414

1515
PATH_TO_JAR=$SERVICE_NAME".jar"
1616
SERVER_URL="http://localhost:$SERVER_PORT"
17-
STARTUP_LOG=$LOG_DIR"/startup.log"
1817

1918
if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
2019
export JAVA_HOME=/usr/java/latest/
@@ -47,7 +46,7 @@ if [[ -f $SERVICE_NAME".jar" ]]; then
4746
rm -rf $SERVICE_NAME".jar"
4847
fi
4948

50-
printf "$(date) ==== Starting ==== \n" > $STARTUP_LOG
49+
printf "$(date) ==== Starting ==== \n"
5150

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

5857
if [[ $rc != 0 ]];
5958
then
60-
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc" >> $STARTUP_LOG
59+
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc"
6160
exit $rc;
6261
fi
6362

6463
declare -i counter=0
6564
declare -i max_counter=16 # 16*5=80s
6665
declare -i total_time=0
6766

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

7877
if [[ (( counter -ge max_counter )) ]];
7978
then
80-
printf "\n$(date) Server failed to start in $total_time seconds!\n" >> $STARTUP_LOG
79+
printf "\n$(date) Server failed to start in $total_time seconds!\n"
8180
exit 1;
8281
fi
8382

84-
printf "\n$(date) Server started in $total_time seconds!\n" >> $STARTUP_LOG
83+
printf "\n$(date) Server started in $total_time seconds!\n"
8584

8685
exit 0;

apollo-portal/src/main/scripts/startup.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/
1414

1515
PATH_TO_JAR=$SERVICE_NAME".jar"
1616
SERVER_URL="http://localhost:$SERVER_PORT"
17-
STARTUP_LOG=$LOG_DIR"/startup.log"
1817

1918
if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
2019
export JAVA_HOME=/usr/java/latest/
@@ -47,7 +46,7 @@ if [[ -f $SERVICE_NAME".jar" ]]; then
4746
rm -rf $SERVICE_NAME".jar"
4847
fi
4948

50-
printf "$(date) ==== Starting ==== \n" > $STARTUP_LOG
49+
printf "$(date) ==== Starting ==== \n"
5150

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

5857
if [[ $rc != 0 ]];
5958
then
60-
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc" >> $STARTUP_LOG
59+
echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc"
6160
exit $rc;
6261
fi
6362

6463
declare -i counter=0
6564
declare -i max_counter=16 # 16*5=80s
6665
declare -i total_time=0
6766

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

7877
if [[ (( counter -ge max_counter )) ]];
7978
then
80-
printf "\n$(date) Server failed to start in $total_time seconds!\n" >> $STARTUP_LOG
79+
printf "\n$(date) Server failed to start in $total_time seconds!\n"
8180
exit 1;
8281
fi
8382

84-
printf "\n$(date) Server started in $total_time seconds!\n" >> $STARTUP_LOG
83+
printf "\n$(date) Server started in $total_time seconds!\n"
8584

8685
exit 0;

0 commit comments

Comments
 (0)