From 1e42f54fad8f51f8a0e07f6668f04e75f9e9a3a4 Mon Sep 17 00:00:00 2001 From: coco3x Date: Fri, 13 Dec 2024 21:36:41 +0900 Subject: [PATCH] =?UTF-8?q?update:=20=EC=9A=B4=EC=98=81=EC=B2=B4=EC=A0=9C?= =?UTF-8?q?=EB=A5=BC=20=ED=99=95=EC=9D=B8=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EA=B3=A0=20prod=EB=A9=B4=20=EA=B2=80=EC=A6=9D=EC=9D=84=20?= =?UTF-8?q?=EC=8B=9C=EB=8F=84=20=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommandInstalledValidator.java | 1 + .../system_validator/SystemValidator.java | 3 ++ .../SystemValidatorConfig.java | 45 ------------------- 3 files changed, 4 insertions(+), 45 deletions(-) delete mode 100644 modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidatorConfig.java diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/CommandInstalledValidator.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/CommandInstalledValidator.java index d7ab500..1ccef9c 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/CommandInstalledValidator.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/CommandInstalledValidator.java @@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +//which로 커맨드가 설치되어있는지 확인함 @Component @RequiredArgsConstructor public class CommandInstalledValidator implements Validator { diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidator.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidator.java index 085a2ed..b67745d 100644 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidator.java +++ b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidator.java @@ -11,10 +11,13 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; //시스템의 전체적인 검증을 진행하는 클래스 //SystemValidatorConfig에 의해 빈으로 등록됩니다 @Slf4j +@Profile("prod") +@Component public final class SystemValidator { private final NetworkConfig config; private final SystemNetworkInterfaces systemNIs; diff --git a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidatorConfig.java b/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidatorConfig.java deleted file mode 100644 index 8660b74..0000000 --- a/modules/infrastructure/log-writer/src/main/java/com/whoz_in/log_writer/system_validator/SystemValidatorConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.whoz_in.log_writer.system_validator; - -import com.whoz_in.log_writer.common.SystemNetworkInterfaces; -import com.whoz_in.log_writer.config.NetworkConfig; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - - -//TODO: Conditional로 뺄지 아니면 -@Slf4j -@Configuration -public class SystemValidatorConfig { - private final String profile; - private final NetworkConfig config; - private final SystemNetworkInterfaces systemNIs; - private final CommandInstalledValidator commandInstalledValidator; - private final NetworkInterfaceValidator networkInterfaceValidator; - - public SystemValidatorConfig(@Value("${spring.profiles.active}") String profile, - NetworkConfig config, - SystemNetworkInterfaces systemNIs, - CommandInstalledValidator commandInstalledValidator, - NetworkInterfaceValidator networkInterfaceValidator) { - this.profile = profile; - this.config = config; - this.systemNIs = systemNIs; - this.commandInstalledValidator = commandInstalledValidator; - this.networkInterfaceValidator = networkInterfaceValidator; - } - - @Bean - public SystemValidator systemValidator(){ - String osName = System.getProperty("os.name").toLowerCase(); - log.info("운영체제 - {}", osName); - log.info("스프링 프로필 - {}", profile); - - if (!profile.equals("prod") || !osName.contains("nux")){ - log.info("리눅스가 아니거나 스프링 프로필이 prod가 아니므로 시스템 검증을 수행하지 않습니다."); - return null; - } - return new SystemValidator(config, systemNIs, commandInstalledValidator, networkInterfaceValidator); - } -}