From 274e80634b665f346c08d1b65877e2b3125e1b75 Mon Sep 17 00:00:00 2001 From: jcw1031 Date: Sun, 2 Jun 2024 17:33:07 +0900 Subject: [PATCH] chore: configure logback pattern and appender by active profiles --- .github/workflows/cicd.yml | 3 --- appspec.yml | 2 +- build.gradle | 1 - scripts/start.sh | 14 +++++----- scripts/stop.sh | 8 +++--- src/main/resources/console-appender.xml | 8 ++++++ src/main/resources/file-error-appender.xml | 20 +++++++++++++++ src/main/resources/file-info-appender.xml | 20 +++++++++++++++ src/main/resources/file-warn-appender.xml | 20 +++++++++++++++ src/main/resources/logback-spring.xml | 30 ++++++++++++++++++++++ 10 files changed, 110 insertions(+), 16 deletions(-) create mode 100644 src/main/resources/console-appender.xml create mode 100644 src/main/resources/file-error-appender.xml create mode 100644 src/main/resources/file-info-appender.xml create mode 100644 src/main/resources/file-warn-appender.xml create mode 100644 src/main/resources/logback-spring.xml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 7bae0528..bf2e0ca9 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -4,9 +4,6 @@ on: push: branches: - main -# pull_request: -# branches: -# - main jobs: deploy: diff --git a/appspec.yml b/appspec.yml index 08b51cee..24c0bcd5 100644 --- a/appspec.yml +++ b/appspec.yml @@ -3,7 +3,7 @@ os: linux files: - source: / - destination: /home/ec2-user/deploy + destination: /home/ec2-user/LikeKNU overwrite: yes permissions: diff --git a/build.gradle b/build.gradle index 126bd4cf..54503fa0 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,6 @@ dependencies { testAnnotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' - testImplementation 'io.projectreactor:reactor-test' testImplementation 'org.springframework.amqp:spring-rabbit-test' } diff --git a/scripts/start.sh b/scripts/start.sh index 739ab5ed..ed73f153 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1,7 +1,7 @@ #!/bin/bash -ROOT_PATH="/home/ec2-user/deploy" -JAR="$ROOT_PATH/application.jar" +ROOT_PATH="/home/ec2-user/LikeKNU" +JAR="$ROOT_PATH/LikeKNU.jar" APP_LOG="$ROOT_PATH/application.log" ERROR_LOG="$ROOT_PATH/error.log" @@ -9,12 +9,12 @@ START_LOG="$ROOT_PATH/start.log" NOW=$(date +%c) -echo "[$NOW] $JAR 복사" >> $START_LOG -cp $ROOT_PATH/build/libs/LikeKNU-1.0.0.jar $JAR +echo "[$NOW] Copy $JAR" >> $START_LOG +cp $ROOT_PATH/build/libs/*.jar $JAR -echo "[$NOW] > $JAR 실행" >> $START_LOG +echo "[$NOW] Run $JAR" >> $START_LOG source ~/.bash_profile -nohup java -jar $JAR > $APP_LOG 2> $ERROR_LOG & +nohup java -jar $JAR --spring.profiles.active=prod > $APP_LOG 2> $ERROR_LOG & SERVICE_PID=$(pgrep -f $JAR) -echo "[$NOW] > 서비스 PID: $SERVICE_PID" >> $START_LOG \ No newline at end of file +echo "[$NOW] Application PID: $SERVICE_PID" >> $START_LOG \ No newline at end of file diff --git a/scripts/stop.sh b/scripts/stop.sh index 35065c24..78e34012 100644 --- a/scripts/stop.sh +++ b/scripts/stop.sh @@ -1,13 +1,13 @@ #!/bin/bash -ROOT_PATH="/home/ec2-user/deploy" -JAR="$ROOT_PATH/application.jar" +ROOT_PATH="/home/ec2-user/LikeKNU" +JAR="$ROOT_PATH/LikeKNU.jar" STOP_LOG="$ROOT_PATH/stop.log" SERVICE_PID=$(pgrep -f $JAR) if [ -z "$SERVICE_PID" ]; then - echo "서비스 NotFound" >> $STOP_LOG + echo "Service not found" >> $STOP_LOG else - echo "서비스 종료 " >> $STOP_LOG + echo "Terminate service " >> $STOP_LOG kill -9 "$SERVICE_PID" fi \ No newline at end of file diff --git a/src/main/resources/console-appender.xml b/src/main/resources/console-appender.xml new file mode 100644 index 00000000..35de0d08 --- /dev/null +++ b/src/main/resources/console-appender.xml @@ -0,0 +1,8 @@ + + + + ${LOG_PATTERN} + utf8 + + + diff --git a/src/main/resources/file-error-appender.xml b/src/main/resources/file-error-appender.xml new file mode 100644 index 00000000..f7d75265 --- /dev/null +++ b/src/main/resources/file-error-appender.xml @@ -0,0 +1,20 @@ + + + ${DEFAULT_DIR}/log/error/error-${BY_DATE}.log + + ERROR + ACCEPT + DENY + + + ${LOG_FILE_PATTERN} + utf8 + + + ${DEFAULT_DIR}/backup/error/error-%d{yyyy-MM-dd}.%i.gz + 50MB + 30 + 2GB + + + diff --git a/src/main/resources/file-info-appender.xml b/src/main/resources/file-info-appender.xml new file mode 100644 index 00000000..e7007c94 --- /dev/null +++ b/src/main/resources/file-info-appender.xml @@ -0,0 +1,20 @@ + + + ${DEFAULT_DIR}/log/info/info-${BY_DATE}.log + + INFO + ACCEPT + DENY + + + ${LOG_FILE_PATTERN} + utf8 + + + ${DEFAULT_DIR}/backup/info/info-%d{yyyy-MM-dd}.%i.gz + 50MB + 30 + 2GB + + + diff --git a/src/main/resources/file-warn-appender.xml b/src/main/resources/file-warn-appender.xml new file mode 100644 index 00000000..4418ca81 --- /dev/null +++ b/src/main/resources/file-warn-appender.xml @@ -0,0 +1,20 @@ + + + ${DEFAULT_DIR}/log/warn/warn-${BY_DATE}.log + + WARN + ACCEPT + DENY + + + ${LOG_FILE_PATTERN} + utf8 + + + ${DEFAULT_DIR}/backup/warn/warn-%d{yyyy-MM-dd}.%i.gz + 50MB + 30 + 2GB + + + diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..294b63d0 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +