diff --git a/.github/workflows/backend-ci-cd-prod.yml b/.github/workflows/backend-ci-cd-prod.yml index f5b76e656..0b3378c42 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 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 f46ad49af..a70562b98 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 7173c40a8..5cec1adfa 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 962c51767..ab9e0108d 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 dd1f1d519..d7f0ea177 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"; diff --git a/backend/src/main/resources/application-prod.yml b/backend/src/main/resources/application-prod.yml index bf05843d5..a3dec7649 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