728x90
반응형
파일, 이미지, 폴더 등 저장소로 IPFS 를 사용하고 있는데
스프링 빈으로 등록하여 사용시 자꾸 IPFS 데몬이 꺼지는 문제점이 발생
코드는 다음과 같다.
@Configuration
class IpfsConfig(
private val appProperties: AppProperties,
) {
@Bean
fun ipfs(): IPFS{
return IPFS(appProperties.ipfsHost, 5001)
}
}
왜 그런지 고민을 좀 해보다가 @Bean의 destroy method가 shutdown이나 close를 추론해서 자동으로 빈이 사라지기 전에 호출한다는 것이 기억이 났다. 찾아보니 IPFS Class에 shutdownMethod가 있었고 이것을 자동으로 호출해서 발생하는 문제였다 .
다음과 같이 수정하면 된다.
@Configuration
class IpfsConfig(
private val appProperties: AppProperties,
) {
//자동으로 shutdown을 호출해서 daemon을 shutdown 시킴
@Bean(destroyMethod = "")
fun ipfs(): IPFS{
return IPFS(appProperties.ipfsHost, 5001)
}
}
https://github.com/ipfs-shipyard/java-ipfs-http-client
728x90
반응형
'web study > Spring' 카테고리의 다른 글
Spring mongodb mongoTemplate project stage에서 switch 사용하기 (0) | 2023.11.28 |
---|---|
Intelij gradle 'compilejava' task (current target is 11) and 'compilekotlin' task (current target is 1.8) jvm target compatibility should be set to the same java version. error (0) | 2023.11.23 |
스프링 json 직렬화의 함정 (is가 prefix일 경우 사라짐) (0) | 2023.03.16 |
JPA를 사용하는 이유와 특징 (0) | 2022.04.15 |
객체와 캡슐화에 대해서(객체지향적 코드를 짜는 이유) (0) | 2022.04.10 |