Skip to content

Commit

Permalink
1. switch off console appenders when running as backend services
Browse files Browse the repository at this point in the history
2. upgrade spring-boot-maven-plugin to 2.0.5.RELEASE
  • Loading branch information
nobodyiam committed Jan 10, 2021
1 parent 41519f4 commit 137d70e
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: mvn clean compile -pl apollo-client,apollo-mockserver,apollo-openapi -am -Dmaven.gitcommitid.skip=true
- name: JDK 8
if: matrix.jdk == '8'
run: mvn -B package -P travis jacoco:report -Dmaven.gitcommitid.skip=true
run: mvn -B clean package -P travis jacoco:report -Dmaven.gitcommitid.skip=true
- name: JDK 11
if: matrix.jdk == '11'
run: mvn clean compile -Dmaven.gitcommitid.skip=true
Expand Down
3 changes: 0 additions & 3 deletions apollo-adminservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion apollo-adminservice/src/main/config/apollo-adminservice.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
MODE=service
PID_FOLDER=.
LOG_FOLDER=/opt/logs/100003172/
# console appender log file folder
LOG_FOLDER=/opt/logs/100003172/
# console appender file name
LOG_FILENAME=console.log
# write application logs only to file appender
export LOG_APPENDERS=FILE
20 changes: 18 additions & 2 deletions apollo-adminservice/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
<if condition='isDefined("LOG_APPENDERS")'>
<then>
<if condition='property("LOG_APPENDERS").contains("CONSOLE")'>
<then>
<appender-ref ref="CONSOLE"/>
</then>
</if>
<if condition='property("LOG_APPENDERS").contains("FILE")'>
<then>
<appender-ref ref="FILE"/>
</then>
</if>
</then>
<else>
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</else>
</if>
</root>
</configuration>
1 change: 1 addition & 0 deletions apollo-adminservice/src/main/scripts/shutdown.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
SERVICE_NAME=apollo-adminservice
export APP_NAME=$SERVICE_NAME

if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
export JAVA_HOME=/usr/java/latest/
Expand Down
3 changes: 2 additions & 1 deletion apollo-adminservice/src/main/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ then
export SPRING_DATASOURCE_PASSWORD=$DS_PASSWORD
fi
export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"
export APP_NAME=$SERVICE_NAME

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`
for i in `ls -t $APP_NAME/$APP_NAME.pid 2>/dev/null`
do
read pid < $i

Expand Down
3 changes: 0 additions & 3 deletions apollo-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
20 changes: 18 additions & 2 deletions apollo-assembly/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
<if condition='isDefined("LOG_APPENDERS")'>
<then>
<if condition='property("LOG_APPENDERS").contains("CONSOLE")'>
<then>
<appender-ref ref="CONSOLE"/>
</then>
</if>
<if condition='property("LOG_APPENDERS").contains("FILE")'>
<then>
<appender-ref ref="FILE"/>
</then>
</if>
</then>
<else>
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</else>
</if>
</root>
</configuration>
5 changes: 3 additions & 2 deletions apollo-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
</exclusion>
</exclusions>
</dependency>
<!-- logback dependencies-->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand Down
3 changes: 0 additions & 3 deletions apollo-configservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
MODE=service
PID_FOLDER=.
LOG_FOLDER=/opt/logs/100003171/
# console appender log file folder
LOG_FOLDER=/opt/logs/100003171/
# console appender log file name
LOG_FILENAME=console.log
# write application logs only to file appender
export LOG_APPENDERS=FILE
20 changes: 18 additions & 2 deletions apollo-configservice/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
<if condition='isDefined("LOG_APPENDERS")'>
<then>
<if condition='property("LOG_APPENDERS").contains("CONSOLE")'>
<then>
<appender-ref ref="CONSOLE"/>
</then>
</if>
<if condition='property("LOG_APPENDERS").contains("FILE")'>
<then>
<appender-ref ref="FILE"/>
</then>
</if>
</then>
<else>
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</else>
</if>
</root>
</configuration>
1 change: 1 addition & 0 deletions apollo-configservice/src/main/scripts/shutdown.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
SERVICE_NAME=apollo-configservice
export APP_NAME=$SERVICE_NAME

if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
export JAVA_HOME=/usr/java/latest/
Expand Down
3 changes: 2 additions & 1 deletion apollo-configservice/src/main/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ then
export SPRING_DATASOURCE_PASSWORD=$DS_PASSWORD
fi
export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"
export APP_NAME=$SERVICE_NAME

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`
for i in `ls -t $APP_NAME/$APP_NAME.pid 2>/dev/null`
do
read pid < $i

Expand Down
3 changes: 0 additions & 3 deletions apollo-portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion apollo-portal/src/main/config/apollo-portal.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
MODE=service
PID_FOLDER=.
LOG_FOLDER=/opt/logs/100003173/
# console appender log file folder
LOG_FOLDER=/opt/logs/100003173/
# console appender log file name
LOG_FILENAME=console.log
# write application logs only to file appender
export LOG_APPENDERS=FILE
20 changes: 18 additions & 2 deletions apollo-portal/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
<if condition='isDefined("LOG_APPENDERS")'>
<then>
<if condition='property("LOG_APPENDERS").contains("CONSOLE")'>
<then>
<appender-ref ref="CONSOLE"/>
</then>
</if>
<if condition='property("LOG_APPENDERS").contains("FILE")'>
<then>
<appender-ref ref="FILE"/>
</then>
</if>
</then>
<else>
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
</else>
</if>
</root>
</configuration>
1 change: 1 addition & 0 deletions apollo-portal/src/main/scripts/shutdown.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
SERVICE_NAME=apollo-portal
export APP_NAME=$SERVICE_NAME

if [[ -z "$JAVA_HOME" && -d /usr/java/latest/ ]]; then
export JAVA_HOME=/usr/java/latest/
Expand Down
3 changes: 2 additions & 1 deletion apollo-portal/src/main/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ then
export SPRING_DATASOURCE_PASSWORD=$DS_PASSWORD
fi
export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"
export APP_NAME=$SERVICE_NAME

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`
for i in `ls -t $APP_NAME/$APP_NAME.pid 2>/dev/null`
do
read pid < $i

Expand Down
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,11 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.3.5.RELEASE</version>
<version>${spring-boot.version}</version>
<configuration>
<executable>true</executable>
<attach>false</attach>
</configuration>
<executions>
<execution>
<goals>
Expand Down

0 comments on commit 137d70e

Please sign in to comment.