From 0eadbaf9e79b27fa0e06103b8e60fd925b10370b Mon Sep 17 00:00:00 2001 From: Songyi Kim Date: Sun, 10 Nov 2024 18:35:59 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EC=8A=AC=EB=9E=99=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=20=EC=B1=84=EB=84=90=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 ++ .../goalpanzi/GoalpanziApplication.java | 16 +++++++-- .../resources/appenders/slack-appender.xml | 34 +++++++++++++++++++ src/main/resources/application.yml | 3 ++ src/main/resources/logback-spring.xml | 7 ++++ 5 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/appenders/slack-appender.xml diff --git a/build.gradle b/build.gradle index d37dd739..3551686f 100644 --- a/build.gradle +++ b/build.gradle @@ -60,6 +60,9 @@ dependencies { // firebase implementation 'com.google.firebase:firebase-admin:9.3.0' + // slack + implementation 'com.github.maricn:logback-slack-appender:1.6.1' + compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' diff --git a/src/main/java/com/nexters/goalpanzi/GoalpanziApplication.java b/src/main/java/com/nexters/goalpanzi/GoalpanziApplication.java index 50c0590d..ae8f7423 100644 --- a/src/main/java/com/nexters/goalpanzi/GoalpanziApplication.java +++ b/src/main/java/com/nexters/goalpanzi/GoalpanziApplication.java @@ -1,13 +1,23 @@ package com.nexters.goalpanzi; +import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import java.util.TimeZone; + @SpringBootApplication public class GoalpanziApplication { - public static void main(String[] args) { - SpringApplication.run(GoalpanziApplication.class, args); - } + public static void main(String[] args) { + var ctx = SpringApplication.run(GoalpanziApplication.class, args); + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")); + var serverPort = ctx.getEnvironment().getProperty("server.port"); + var profile = ctx.getEnvironment().getProperty("spring.profiles.active"); + // startup notification + String banner = String.format("GoalpanziApplication started (profile=%s, port=%s)", profile, serverPort); + System.out.println(banner); + LoggerFactory.getLogger("ServerBoot").info(banner); + } } diff --git a/src/main/resources/appenders/slack-appender.xml b/src/main/resources/appenders/slack-appender.xml new file mode 100644 index 00000000..711743f6 --- /dev/null +++ b/src/main/resources/appenders/slack-appender.xml @@ -0,0 +1,34 @@ + + + + + [%thread] %-5level traceId:"%X{traceId:-}" spanId:"%X{spanId:-}"%n%msg%n + + + ${SLACK_WEBHOOK_URI} + ${SLACK_USERNAME} + ${SLACK_CHANNEL} + :bell: + true + + ! + + + + ERROR + + + + + + + *Server Name:* `${HOSTNAME:-}` %n%msg%n + + + ${SLACK_WEBHOOK_URI} + ${SLACK_USERNAME} + ${SLACK_CHANNEL} + :bell: + true + + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c92e1cb8..f04b40db 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,6 @@ +server: + port: 8080 + spring: h2: console: diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index a9a1b8d5..ef2423c6 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,5 +1,7 @@ + + @@ -36,5 +38,10 @@ + + + + + From ea3f587c489ccabf1f1486765d771b0eee0e5853 Mon Sep 17 00:00:00 2001 From: Songyi Kim Date: Sun, 10 Nov 2024 18:42:24 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20properties.xml=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/logback-spring.xml | 2 +- src/main/resources/properties.xml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/properties.xml diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index ef2423c6..0706ff53 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,6 +1,6 @@ - + + + + + From e3da609541faca026a4438f9fc5de8bc6e6dcdeb Mon Sep 17 00:00:00 2001 From: Songyi Kim Date: Sun, 10 Nov 2024 18:47:05 +0900 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20webhook=20uri=20=EC=9E=AC=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=EB=85=B8=EC=B6=9C=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 1 + docker-compose.yml | 1 + src/main/resources/properties.xml | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 66d9f125..b5fab306 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -74,6 +74,7 @@ jobs: export OBJECT_STORAGE_ACCESS_KEY_ID=${{ secrets.OBJECT_STORAGE_ACCESS_KEY_ID }} export OBJECT_STORAGE_SECRET_KEY=${{ secrets.OBJECT_STORAGE_SECRET_KEY }} export ENCODED_FIREBASE_ADMIN_SDK=${{ secrets.ENCODED_FIREBASE_ADMIN_SDK }} + export SLACK_WEBHOOK_URI=${{ secrets.SLACK_WEBHOOK_URI }} sudo docker rm -f $(docker ps -qa) diff --git a/docker-compose.yml b/docker-compose.yml index b13d935f..d41e7d91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,7 @@ services: OBJECT_STORAGE_ACCESS_KEY_ID: ${OBJECT_STORAGE_ACCESS_KEY_ID} OBJECT_STORAGE_SECRET_KEY: ${OBJECT_STORAGE_SECRET_KEY} ENCODED_FIREBASE_ADMIN_SDK: ${ENCODED_FIREBASE_ADMIN_SDK} + SLACK_WEBHOOK_URI: ${SLACK_WEBHOOK_URI} restart: always volumes: - ./logs:/logs diff --git a/src/main/resources/properties.xml b/src/main/resources/properties.xml index 501c33a2..82cc13e2 100644 --- a/src/main/resources/properties.xml +++ b/src/main/resources/properties.xml @@ -1,6 +1,4 @@ - From 879033d7e704021dd4ab0ae4976273f1a4df694a Mon Sep 17 00:00:00 2001 From: Songyi Kim Date: Sun, 10 Nov 2024 18:51:18 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20prod=20logback=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-prod.yml | 2 ++ src/main/resources/{logback-spring.xml => logback-prod.xml} | 0 2 files changed, 2 insertions(+) rename src/main/resources/{logback-spring.xml => logback-prod.xml} (100%) diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 6ec905ce..934e235e 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -64,3 +64,5 @@ oauth: iss: https://appleid.apple.com client-id: ${OAUTH_APPLE_CLIENT_ID} +logging: + config: classpath:logback-prod.xml \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-prod.xml similarity index 100% rename from src/main/resources/logback-spring.xml rename to src/main/resources/logback-prod.xml