Skip to content

Commit

Permalink
Merge pull request #128 from Gachon-Table/develop
Browse files Browse the repository at this point in the history
v1.0.5
  • Loading branch information
jwnnoh authored Oct 29, 2024
2 parents fa07652 + 5cb064d commit 1248dc3
Show file tree
Hide file tree
Showing 15 changed files with 329 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ jobs:
sudo docker rm $(sudo docker ps --filter 'status=exited' -a -q)
sudo docker run -d -v /home/ubuntu/pinpoint-agent-2.5.3:/pinpoint-agent --log-driver=syslog --name lupg -p 8080:8080 -p 63544:63544 -e JAVA_OPTS=-Djasypt.encryptor.password=${{secrets.JASYPT_ENCRYPTOR_PASSWORD}} ${{secrets.DOCKER_USERNAME}}/gachontable:latest
sudo docker image prune -a -f
sudo docker image prune -a -f
58 changes: 58 additions & 0 deletions .github/workflows/prod-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: prod-CI

on:
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]

jobs:
prod-ci:
runs-on: ubuntu-latest

steps:
# Checkout - 가상 머신에 체크아웃
- name: Checkout code
uses: actions/checkout@v3

# JDK setting - JDK 17 설정
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'

# gradle caching - 빌드 시간 향상
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# gradle build - 테스트 없이 gradle 빌드
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew build -x test
shell: bash

# Set up Docker Buildx - Docker Buildx 설치
- name: Set up Docker Buildx
uses: docker/[email protected]

# Log in to Docker Hub - Docker Hub 로그인
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.PROD_DOCKER_USERNAME }}
password: ${{ secrets.PROD_DOCKER_ACCESS_TOKEN }}

# Build and push Docker image - Docker image 빌드 및 푸시
- name: Build and push Docker image
run: |
docker build --platform linux/amd64 -t ${{ secrets.PROD_DOCKER_USERNAME }}/lupg .
docker push ${{ secrets.PROD_DOCKER_USERNAME }}/lupg
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

COPY build/libs/*.jar gachontable.jar

ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -Dspring.profiles.active=dev -javaagent:/pinpoint-agent/pinpoint-bootstrap-2.5.3.jar -Dpinpoint.agentId=LUPG -Dpinpoint.applicationName=LUPG-Dev -jar /gachontable.jar"]
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -Dspring.profiles.active=prod -javaagent:/pinpoint-agent/pinpoint-bootstrap-2.5.3.jar -Dpinpoint.agentId=LUPG -Dpinpoint.applicationName=LUPG-Prod -jar /gachontable.jar"]
7 changes: 7 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM openjdk:17-jdk

RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

COPY build/libs/*.jar gachontable.jar

ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -Dspring.profiles.active=dev -javaagent:/pinpoint-agent/pinpoint-bootstrap-2.5.3.jar -Dpinpoint.agentId=LUPG -Dpinpoint.applicationName=LUPG-Dev -jar /gachontable.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CallUser {
private final AdminRepository adminRepository;
private final SendBiztalk sendBiztalk;
private final AutoCancelUser autoCancelUser;
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(4);
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(8);

@Value("${biztalk.templateId.call}")
private String CALL_TEMPLATE_CODE;
Expand All @@ -58,7 +58,7 @@ public String execute(AuthDetails authDetails, CallUserRequest request, String l

private void scheduleAutoCancel(UUID waitingId, HashMap<String, String> variables) {
executorService.schedule(() ->
autoCancelUser.execute(waitingId, variables, "자동 취소"), 1, TimeUnit.MINUTES);
autoCancelUser.execute(waitingId, variables, "자동 취소"), 5, TimeUnit.MINUTES);
}

private void checkPubMatches(AuthDetails authDetails, Pub pub) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -49,7 +48,7 @@ public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
String className = joinPoint.getSignature().getDeclaringType().getSimpleName();
String method = joinPoint.getSignature().getName();

log.info("{}.{} | time = {}ms", className, method, duration);
log.info("{}.{} | time = {}ms", className, method, duration);
}
}

Expand Down Expand Up @@ -77,9 +76,12 @@ public void logController(JoinPoint joinPoint) {
log.error("LogAspect Error", e);
}

log.info("[{}] {}", params.get("http_method"), params.get("request_uri"));
log.info("method: {}.{}", params.get("controller"), params.get("method"));
log.info("params: {}", params.get("params"));
log.info("🛫[{}] {}\nmethod: {}.{}\nparams: {}",
params.get("http_method"),
params.get("request_uri"),
params.get("controller"),
params.get("method"),
params.get("params"));
}

private JSONObject getParams(HttpServletRequest request) {
Expand Down Expand Up @@ -107,23 +109,6 @@ public void logAfterController(JoinPoint joinPoint, Object result) {
log.info("✅End: {}() - {}", methodName, result);
}

// Before 어드바이스를 통한 서비스 메서드 시작 로깅
@Before(value = "publicMethodsFromService()")
public void logBeforeService(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
String methodName = joinPoint.getSignature().getDeclaringType().getSimpleName();

log.info("⚠️Start: {}() - {}", methodName, Arrays.toString(args));
}

// After 어드바이스를 통한 서비스 메서드 종료 로깅
@AfterReturning(value = "publicMethodsFromService()")
public void logAfterService(JoinPoint joinPoint) {
String methodName = joinPoint.getSignature().getDeclaringType().getSimpleName();

log.info("✅End: {}()", methodName);
}

// AfterThrowing 어드바이스를 통한 오류 로깅
@AfterThrowing(pointcut = "publicMethodsFromService()", throwing = "exception")
public void logException(JoinPoint joinPoint, Throwable exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class AsyncConfiguration {
@Bean
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setMaxPoolSize(6);
executor.setQueueCapacity(500);
executor.setCorePoolSize(8);
executor.setMaxPoolSize(16);
executor.setQueueCapacity(1000);
executor.setThreadNamePrefix("Biztalk");
executor.initialize();
return executor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package site.gachontable.gachontablebe.global.config.aurora;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import org.springframework.transaction.support.TransactionSynchronizationManager;

public class CustomRoutingDataSource extends AbstractRoutingDataSource {

@Override
protected Object determineCurrentLookupKey() {
return TransactionSynchronizationManager.isCurrentTransactionReadOnly() ? "slave" : "master";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package site.gachontable.gachontablebe.global.config.aurora;

import com.zaxxer.hikari.HikariDataSource;
import java.util.HashMap;
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.DependsOn;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;

@Configuration
public class TransactionConfig {

private static final String MASTER_DATASOURCE = "masterDataSource";
private static final String SLAVE_DATASOURCE = "slaveDataSource";

@Bean(name = MASTER_DATASOURCE)
@ConfigurationProperties(prefix = "spring.datasource.master.hikari")
public HikariDataSource masterDataSource() {
return DataSourceBuilder.create()
.type(HikariDataSource.class)
.build();
}

@Bean(name = SLAVE_DATASOURCE)
@ConfigurationProperties("spring.datasource.slave.hikari")
public HikariDataSource slaveDataSource() {
HikariDataSource dataSource = DataSourceBuilder.create()
.type(HikariDataSource.class)
.build();
dataSource.setReadOnly(true);
return dataSource;
}

@Bean
public CustomRoutingDataSource routingDataSource() {
CustomRoutingDataSource routingDataSource = new CustomRoutingDataSource();
HashMap<Object, Object> dataSources = new HashMap<>();
dataSources.put("master", masterDataSource());
dataSources.put("slave", slaveDataSource());
routingDataSource.setTargetDataSources(dataSources);
routingDataSource.setDefaultTargetDataSource(masterDataSource());
return routingDataSource;
}

@Bean
@Primary
@DependsOn("routingDataSource")
public DataSource dataSource(CustomRoutingDataSource routingDataSource) {
return new LazyConnectionDataSourceProxy(routingDataSource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,21 @@ public class RedissonConfig {
private String redisPassword;

private static final String REDISSON_HOST_PREFIX = "rediss://";
private static final String REDISSON_PRIMARY_PREFIX = "gachontable-001.";
private static final String REDISSON_REPLICA_1_PREFIX = "gachontable-002.";
private static final String REDISSON_REPLICA_2_PREFIX = "gachontable-003.";
private static final String REDISSON_REPLICA_3_PREFIX = "gachontable-004.";

@Bean
public RedissonClient redissonClient() {
Config config = new Config();
config.useSingleServer()
.setAddress(REDISSON_HOST_PREFIX + redisHost + ":" + redisPort + "/" + redisDatabase)
config.useReplicatedServers()
.addNodeAddress(
REDISSON_HOST_PREFIX + REDISSON_PRIMARY_PREFIX + redisHost + ":" + redisPort + "/" + redisDatabase,
REDISSON_HOST_PREFIX + REDISSON_REPLICA_1_PREFIX + redisHost + ":" + redisPort + "/" + redisDatabase,
REDISSON_HOST_PREFIX + REDISSON_REPLICA_2_PREFIX + redisHost + ":" + redisPort + "/" + redisDatabase,
REDISSON_HOST_PREFIX + REDISSON_REPLICA_3_PREFIX + redisHost + ":" + redisPort + "/" + redisDatabase
)
.setPassword(redisPassword);
return Redisson.create(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class JwtProvider {

public static final Duration REFRESH_TOKEN_DURATION = Duration.ofDays(14);
public static final Duration ACCESS_TOKEN_DURATION = Duration.ofHours(6);
public static final Duration ACCESS_TOKEN_DURATION = Duration.ofDays(6);

private final SecretKey secretKey;
private final AdminAuthDetailsService adminAuthDetailsService;
Expand Down
40 changes: 33 additions & 7 deletions src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
spring:
datasource:
url: ENC(rXVivRZ2+Z7AZQnwYxYVsXbLr2e4fifb/REZbpxgSoGW2Vm6u0Gj0/VJOfO1E+emfwXeCoU9N8H0cVuqYuoEWbdPU7kekYIIUG/nL1G4RmxrUPPttsPZGM2WrYG6sWy0)
username: ENC(QTTusIQmcVUiM+fDY8kvubSWvMLTmNCa)
password: ENC(7QKbd+ZODf/6SLG+D+Q15Or6EBw55I6KKYF0UnTqie8=)
driver-class-name: com.mysql.cj.jdbc.Driver
master:
hikari:
jdbc-url: ENC(No2xVMbrMThKztwXF5Es3WLaJGRPGQccGmH8KmA4f808rfZ3e/uD4ta+xSRiCgYM4lF0SdqLDVJJYFzFy9IyPnznnMEGrl27Q4PnGqH7SGwEnMuSQ209rm6LxkwLjWgcLM8ftOrXeVRgibrK67rLThvDEfeFV63l8rrb96Ta5AO1Oc1jyU1rFRC66bQi4zkpJG7hrry0dCuda+nViHJhlLd6baQC/27Mzvw/WKHrwraKBweAylzynQ==)
username: ENC(Z89GsautuOl2p6BefL146A==)
password: ENC(4IWCgJuGPqbikO4xgN8jZRekUWDhUoyuafdh60pKN5M=)
driver-class-name: com.mysql.cj.jdbc.Driver
maximum-pool-size: 10
connection-timeout: 5000
connection-init-sql: SELECT 1
validation-timeout: 2000
minimum-idle: 10
idle-timeout: 600000
max-lifetime: 1800000
slave:
hikari:
jdbc-url: ENC(mY5hrqcQG63c6yVdIbvFgudXbx5ZFQlaPkT5LQUweKpoKSnd5Cm7/OSqQGMJ+u8WWrIw18IGLnEUKoKJ6/MKAUKrsuaemK6UD5t4a/7lCWriTjqfzpLJVq2x1+MXcjsD6JCK7As5QjkUKykw8ztMDFx/8sItP2sMjnJ/fAQSZjbG+Cs75CDtXaajDrPp6Lf34Rp1d8qphi+OIUfoY2ZUlnCEV8UArYTw6DB+VZZrRaChKtGUJREGDesmohQKCkN1)
username: ENC(Z89GsautuOl2p6BefL146A==)
password: ENC(4IWCgJuGPqbikO4xgN8jZRekUWDhUoyuafdh60pKN5M=)
driver-class-name: com.mysql.cj.jdbc.Driver
maximum-pool-size: 10
connection-timeout: 5000
connection-init-sql: SELECT 1
validation-timeout: 2000
minimum-idle: 10
idle-timeout: 600000
max-lifetime: 1800000

jpa:
show-sql: false
hibernate:
Expand All @@ -16,6 +39,7 @@ spring:
jdbc:
time_zone: Asia/Seoul
open-in-view: false

security:
oauth2:
client:
Expand All @@ -38,12 +62,14 @@ spring:
- phone_number
data:
redis:
host: ENC(/NpEAhELSxNKtP4v3/sSnxebuAUEXER6zYWibHeUomRRLa96Y+mJeae5nGt2rUoTaadaS4t+XxvXEEttcNPhBw==)
host: ENC(nsPLWjIX5Q5FBTaBMqK5bCos+m2K8hv+qWFYxAj269ql+2WWeKXExEA8VAVteqotW2FZyTNgbRU=)
port: 6379
database: 0
password: ENC(DURHuRsSmaDEKcx7C9kllvKrNnthDcNZNcPCI7l+0bk=)
ssl:
enabled: true
repositories:
enabled: false

jwt:
secret_key: ENC(CJzB4FyuHQrRdJ9V+3J0GhZbhxevmxah4rJItf5dM0GJj6Rmq2AsaVHFfSuSBPNmOsckPdYUjSxhheiOR3kJGm1i2+zpO4JdiN8GAv6i1zc=)
Expand All @@ -55,10 +81,10 @@ biztalk:
sender_phoneNumber: ENC(oUI8aODxdLXMsFy8AdNSXMnyWXqzj0/1)
templateId:
call: ENC(CGOu3LjBj919zkRKkEf86epBCWUZ3TJJhVXnl7QfKnyRiUJA1/5CfUiWyJcjTOjt)
cancel: ENC(LQRVbWO+DLV2jWam066LfZ+SynyQeSGmGNS4pfcLP4vqSFpLaFYT3otPohV8pUAm)
cancel: ENC(Ff2tfrLsxsZ9LJpJpGtQgy1hsB4l9cymj6zczjjw4/jzQKDOslxJn+2VvQ5QZg4/)
forceCancel: ENC(yEIJoeLcbFwRqdPjOy0W5+4uwSIHUhbHDpWG98jOorBqc98td/mVpoD88ELUNwab)
ready: ENC(FquVHugagxaoGrTmagapeIFhF/g/0ZKDBCB76kBBV29d/iXqxH9RFMuqkLRW+wuW)
waiting: ENC(Wxlr4G0k37PAuVwMNnoTQm8rCgVMjLmHb5ifQJf8sKLQOT3KzlIUUf4DYjlh8P1e)
waiting: ENC(DQuBlQzz4/Lo1dXfTWtwthICNLzAS44GtpaTHaa3k8mnJ3zq1BtdvMo9Ak/TYcKn)

management:
server:
Expand Down
22 changes: 16 additions & 6 deletions src/main/resources/application-local.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
spring:
datasource:
url: jdbc:mysql://localhost:3306/gachontable
username: root
password:
driver-class-name: com.mysql.cj.jdbc.Driver
master:
hikari:
jdbc-url: jdbc:mysql://localhost:3306/gachontable
username: root
password:
driver-class-name: com.mysql.cj.jdbc.Driver
slave:
hikari:
jdbc-url: jdbc:mysql://localhost:3306/gachontable
username: root
password:
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
show-sql: false
hibernate:
Expand Down Expand Up @@ -43,6 +51,8 @@ spring:
port: 6379
database: 0
password: ENC(DURHuRsSmaDEKcx7C9kllvKrNnthDcNZNcPCI7l+0bk=)
repositories:
enabled: false

jwt:
secret_key: ENC(CJzB4FyuHQrRdJ9V+3J0GhZbhxevmxah4rJItf5dM0GJj6Rmq2AsaVHFfSuSBPNmOsckPdYUjSxhheiOR3kJGm1i2+zpO4JdiN8GAv6i1zc=)
Expand All @@ -54,10 +64,10 @@ biztalk:
sender_phoneNumber: ENC(oUI8aODxdLXMsFy8AdNSXMnyWXqzj0/1)
templateId:
call: ENC(CGOu3LjBj919zkRKkEf86epBCWUZ3TJJhVXnl7QfKnyRiUJA1/5CfUiWyJcjTOjt)
cancel: ENC(LQRVbWO+DLV2jWam066LfZ+SynyQeSGmGNS4pfcLP4vqSFpLaFYT3otPohV8pUAm)
cancel: ENC(Ff2tfrLsxsZ9LJpJpGtQgy1hsB4l9cymj6zczjjw4/jzQKDOslxJn+2VvQ5QZg4/)
forceCancel: ENC(yEIJoeLcbFwRqdPjOy0W5+4uwSIHUhbHDpWG98jOorBqc98td/mVpoD88ELUNwab)
ready: ENC(FquVHugagxaoGrTmagapeIFhF/g/0ZKDBCB76kBBV29d/iXqxH9RFMuqkLRW+wuW)
waiting: ENC(Wxlr4G0k37PAuVwMNnoTQm8rCgVMjLmHb5ifQJf8sKLQOT3KzlIUUf4DYjlh8P1e)
waiting: ENC(DQuBlQzz4/Lo1dXfTWtwthICNLzAS44GtpaTHaa3k8mnJ3zq1BtdvMo9Ak/TYcKn)

management:
server:
Expand Down
Loading

0 comments on commit 1248dc3

Please sign in to comment.