From 562939385a480dcd22b9b2c0f551467c17f4aad1 Mon Sep 17 00:00:00 2001 From: yoonjuho Date: Wed, 27 Nov 2024 20:16:44 +0900 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=EC=9A=B4=EC=98=81=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20CD=20=EC=A0=81=EC=9A=A9=20=EC=9D=B8=EC=8A=A4?= =?UTF-8?q?=ED=84=B4=EC=8A=A4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-ci-cd-prod.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/backend-ci-cd-prod.yml b/.github/workflows/backend-ci-cd-prod.yml index f5b76e65..0b3378c4 100644 --- a/.github/workflows/backend-ci-cd-prod.yml +++ b/.github/workflows/backend-ci-cd-prod.yml @@ -63,10 +63,6 @@ jobs: needs: ci runs-on: [ self-hosted, prod ] - strategy: - matrix: - runner: [ prod-a, prod-b ] - steps: - name: execute deploy.sh run: bash /home/ubuntu/staccato/deploy.sh From 6d9967e3ff08f579e88208af07aa53f34a96b94e Mon Sep 17 00:00:00 2001 From: yoonjuho Date: Wed, 27 Nov 2024 20:26:46 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20DataSource=20Config=20=EB=B9=84?= =?UTF-8?q?=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../staccato/config/db/DataSourceConfig.java | 23 +++++++++---------- .../config/db/DynamicRoutingDataSource.java | 13 +++++++---- .../config/db/ReaderDataSourceConfig.java | 12 +++++----- .../config/db/WriterDataSourceConfig.java | 12 +++++----- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/backend/src/main/java/com/staccato/config/db/DataSourceConfig.java b/backend/src/main/java/com/staccato/config/db/DataSourceConfig.java index f46ad49a..a70562b9 100644 --- a/backend/src/main/java/com/staccato/config/db/DataSourceConfig.java +++ b/backend/src/main/java/com/staccato/config/db/DataSourceConfig.java @@ -1,29 +1,28 @@ package com.staccato.config.db; -import static com.staccato.config.db.ReaderDataSourceConfig.READER; -import static com.staccato.config.db.ReaderDataSourceConfig.READER_DATA_SOURCE; -import static com.staccato.config.db.WriterDataSourceConfig.WRITER; -import static com.staccato.config.db.WriterDataSourceConfig.WRITER_DATA_SOURCE; - import java.util.HashMap; import java.util.Map; - import javax.sql.DataSource; - import jakarta.persistence.EntityManagerFactory; - import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Profile; import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.transaction.PlatformTransactionManager; -@Configuration -@Profile("prod") +import static com.staccato.config.db.ReaderDataSourceConfig.READER; +import static com.staccato.config.db.ReaderDataSourceConfig.READER_DATA_SOURCE; +import static com.staccato.config.db.WriterDataSourceConfig.WRITER; +import static com.staccato.config.db.WriterDataSourceConfig.WRITER_DATA_SOURCE; + +/** + * DB Replication을 위한 DataSource 설정 파일입니다. + * 지금은 사용하지 않은 상태로 Disable 상태입니다. + *

+ * 만약, 다시 사용하게 된다면 @Profile, @Configuration 설정이 필요합니다. + */ public class DataSourceConfig { @DependsOn({WRITER_DATA_SOURCE, READER_DATA_SOURCE}) @Bean diff --git a/backend/src/main/java/com/staccato/config/db/DynamicRoutingDataSource.java b/backend/src/main/java/com/staccato/config/db/DynamicRoutingDataSource.java index 7173c40a..5cec1adf 100644 --- a/backend/src/main/java/com/staccato/config/db/DynamicRoutingDataSource.java +++ b/backend/src/main/java/com/staccato/config/db/DynamicRoutingDataSource.java @@ -1,14 +1,17 @@ package com.staccato.config.db; -import static org.springframework.transaction.support.TransactionSynchronizationManager.isCurrentTransactionReadOnly; +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; +import lombok.extern.slf4j.Slf4j; +import static org.springframework.transaction.support.TransactionSynchronizationManager.isCurrentTransactionReadOnly; import static com.staccato.config.db.ReaderDataSourceConfig.READER; import static com.staccato.config.db.WriterDataSourceConfig.WRITER; -import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; - -import lombok.extern.slf4j.Slf4j; - +/** + * DB Replication을 위한 DataSource 설정 파일입니다. + * 지금은 사용하지 않은 상태로 Disable 상태입니다. + *

+ */ @Slf4j public class DynamicRoutingDataSource extends AbstractRoutingDataSource { @Override diff --git a/backend/src/main/java/com/staccato/config/db/ReaderDataSourceConfig.java b/backend/src/main/java/com/staccato/config/db/ReaderDataSourceConfig.java index 962c5176..ab9e0108 100644 --- a/backend/src/main/java/com/staccato/config/db/ReaderDataSourceConfig.java +++ b/backend/src/main/java/com/staccato/config/db/ReaderDataSourceConfig.java @@ -1,17 +1,17 @@ package com.staccato.config.db; import javax.sql.DataSource; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - import com.zaxxer.hikari.HikariDataSource; -@Configuration -@Profile("prod") +/** + * DB Replication을 위한 DataSource 설정 파일입니다. + * 지금은 사용하지 않은 상태로 Disable 상태입니다. + *

+ * 만약, 다시 사용하게 된다면 @Profile, @Configuration 설정이 필요합니다. + */ public class ReaderDataSourceConfig { protected static final String READER_DATA_SOURCE = "readerDataSource"; protected static final String READER = "reader"; diff --git a/backend/src/main/java/com/staccato/config/db/WriterDataSourceConfig.java b/backend/src/main/java/com/staccato/config/db/WriterDataSourceConfig.java index dd1f1d51..d7f0ea17 100644 --- a/backend/src/main/java/com/staccato/config/db/WriterDataSourceConfig.java +++ b/backend/src/main/java/com/staccato/config/db/WriterDataSourceConfig.java @@ -1,17 +1,17 @@ package com.staccato.config.db; import javax.sql.DataSource; - import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - import com.zaxxer.hikari.HikariDataSource; -@Configuration -@Profile("prod") +/** + * DB Replication을 위한 DataSource 설정 파일입니다. + * 지금은 사용하지 않은 상태로 Disable 상태입니다. + *

+ * 만약, 다시 사용하게 된다면 @Profile, @Configuration 설정이 필요합니다. + */ public class WriterDataSourceConfig { protected static final String WRITER_DATA_SOURCE = "writerDataSource"; protected static final String WRITER = "writer"; From 5c4c3cf15dcaede9d788a67e50902ee24e141a1d Mon Sep 17 00:00:00 2001 From: linirini <2001yerin@naver.com> Date: Thu, 28 Nov 2024 11:28:13 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20application-prod.yml=20datasource?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: YoonJuHo Co-authored-by: BurningFalls --- .../src/main/resources/application-prod.yml | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/backend/src/main/resources/application-prod.yml b/backend/src/main/resources/application-prod.yml index bf05843d..a3dec764 100644 --- a/backend/src/main/resources/application-prod.yml +++ b/backend/src/main/resources/application-prod.yml @@ -8,28 +8,38 @@ spring: init: mode: always datasource: - writer: - hikari: - maximum-pool-size: 10 - minimum-idle: 10 - idle-timeout: 600000 - connection-timeout: 8000 - max-lifetime: 1800000 - driver-class-name: com.mysql.cj.jdbc.Driver - jdbcUrl: ${SPRING_WRITER_DATASOURCE_URL} - username: ${SPRING_DATASOURCE_USERNAME} - password: ${SPRING_DATASOURCE_PASSWORD} - reader: - hikari: - maximum-pool-size: 10 - minimum-idle: 10 - idle-timeout: 600000 - connection-timeout: 8000 - max-lifetime: 1800000 - driver-class-name: com.mysql.cj.jdbc.Driver - jdbcUrl: ${SPRING_READER_DATASOURCE_URL} - username: ${SPRING_DATASOURCE_USERNAME} - password: ${SPRING_DATASOURCE_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + url: ${SPRING_DATASOURCE_URL} + username: ${SPRING_DATASOURCE_USERNAME} + password: ${SPRING_DATASOURCE_PASSWORD} + hikari: + maximum-pool-size: 10 + minimum-idle: 10 + idle-timeout: 600000 + connection-timeout: 8000 + max-lifetime: 1800000 +# writer: +# hikari: +# maximum-pool-size: 10 +# minimum-idle: 10 +# idle-timeout: 600000 +# connection-timeout: 8000 +# max-lifetime: 1800000 +# driver-class-name: com.mysql.cj.jdbc.Driver +# jdbcUrl: ${SPRING_WRITER_DATASOURCE_URL} +# username: ${SPRING_DATASOURCE_USERNAME} +# password: ${SPRING_DATASOURCE_PASSWORD} +# reader: +# hikari: +# maximum-pool-size: 10 +# minimum-idle: 10 +# idle-timeout: 600000 +# connection-timeout: 8000 +# max-lifetime: 1800000 +# driver-class-name: com.mysql.cj.jdbc.Driver +# jdbcUrl: ${SPRING_READER_DATASOURCE_URL} +# username: ${SPRING_DATASOURCE_USERNAME} +# password: ${SPRING_DATASOURCE_PASSWORD} jpa: database: MYSQL show-sql: true @@ -45,8 +55,6 @@ spring: flyway: enabled: true locations: classpath:db/migration - baseline-on-migrate: true - baseline-version: 1 servlet: multipart: max-file-size: 20MB