Skip to content

Commit

Permalink
Merge branch 'develop' into feature/#564-refactor-category-datetime-s…
Browse files Browse the repository at this point in the history
…election
  • Loading branch information
s6m1n committed Dec 8, 2024
2 parents 8374921 + 87cd6a4 commit 267c465
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 57 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/backend-ci-cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 11 additions & 12 deletions backend/src/main/java/com/staccato/config/db/DataSourceConfig.java
Original file line number Diff line number Diff line change
@@ -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 상태입니다.
* <p>
* 만약, 다시 사용하게 된다면 @Profile, @Configuration 설정이 필요합니다.
*/
public class DataSourceConfig {
@DependsOn({WRITER_DATA_SOURCE, READER_DATA_SOURCE})
@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -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 상태입니다.
* <p>
*/
@Slf4j
public class DynamicRoutingDataSource extends AbstractRoutingDataSource {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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 상태입니다.
* <p>
* 만약, 다시 사용하게 된다면 @Profile, @Configuration 설정이 필요합니다.
*/
public class ReaderDataSourceConfig {
protected static final String READER_DATA_SOURCE = "readerDataSource";
protected static final String READER = "reader";
Expand Down
Original file line number Diff line number Diff line change
@@ -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 상태입니다.
* <p>
* 만약, 다시 사용하게 된다면 @Profile, @Configuration 설정이 필요합니다.
*/
public class WriterDataSourceConfig {
protected static final String WRITER_DATA_SOURCE = "writerDataSource";
protected static final String WRITER = "writer";
Expand Down
56 changes: 32 additions & 24 deletions backend/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 267c465

Please sign in to comment.