Skip to content

Commit

Permalink
feat: 멀티스레드 종료 시 자원 반납 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachneee committed Dec 10, 2024
1 parent 682017b commit 78b7360
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion server/src/main/java/haengdong/event/config/S3Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package haengdong.event.config;

import jakarta.annotation.PreDestroy;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.springframework.context.annotation.Bean;
Expand All @@ -12,6 +13,8 @@ public class S3Config {

private static final int THREAD_POOL_SIZE = 10;

private final ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);

@Bean
public S3Client s3Client() {
return S3Client.builder()
Expand All @@ -21,6 +24,11 @@ public S3Client s3Client() {

@Bean
public ExecutorService executorService() {
return Executors.newFixedThreadPool(THREAD_POOL_SIZE);
return executorService;
}

@PreDestroy
public void shutdown() {
executorService.shutdown();
}
}
4 changes: 4 additions & 0 deletions server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ spring:
max-file-size: 50MB
max-request-size: 300MB

lifecycle:
timeout-per-shutdown-phase: "10s"

h2:
console:
enabled: true
Expand Down Expand Up @@ -69,6 +72,7 @@ server:
enabled: true
threads:
max: 50
shutdown: graceful

kakao:
base-uri: https://kauth.kakao.com
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/resources/config

0 comments on commit 78b7360

Please sign in to comment.