parent
b4aa845927
commit
5cc486067c
Binary file not shown.
Binary file not shown.
@ -1,13 +1,71 @@
|
|||||||
package com.bsmlab.dfx.agent;
|
package com.bsmlab.dfx.agent;
|
||||||
|
|
||||||
|
import com.bsmlab.dfx.agent.config.AgentConfigDto;
|
||||||
|
import com.fasterxml.jackson.databind.DatabindException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class DfxAgentApplication {
|
public class DfxAgentApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(DfxAgentApplication.class, args);
|
//--setting.file=$AGENT_HOME/conf/settings.json --setting.check
|
||||||
|
// --parse.message.file
|
||||||
|
boolean hasSettingFile = false;
|
||||||
|
boolean hasSettingCheck = false;
|
||||||
|
boolean hasParseMessageFile = false;
|
||||||
|
String settingFilePath = null;
|
||||||
|
if(args != null) {
|
||||||
|
for(String arg : args) {
|
||||||
|
if(arg != null && arg.contains("setting.file")) {
|
||||||
|
if(arg.split("=").length == 2) {
|
||||||
|
settingFilePath = arg.split("=")[1].trim();
|
||||||
|
if(Files.exists(Path.of(settingFilePath))) {
|
||||||
|
hasSettingFile = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(arg != null && arg.contains("setting.check")) {
|
||||||
|
hasSettingCheck = true;
|
||||||
|
}
|
||||||
|
if(arg != null && arg.contains("parse.message.file")) {
|
||||||
|
hasParseMessageFile = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(hasSettingFile && !hasSettingCheck && !hasParseMessageFile) {
|
||||||
|
try {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
AgentConfigDto agentConfigDto = objectMapper.readValue(new File(settingFilePath), AgentConfigDto.class);
|
||||||
|
if(agentConfigDto.isSslEnabled()) {
|
||||||
|
System.setProperty("server.port", String.valueOf(agentConfigDto.getMyListenPort()));
|
||||||
|
System.setProperty("server.ssl.enabled", String.valueOf(agentConfigDto.isSslEnabled()));
|
||||||
|
System.setProperty("server.ssl.key-store", agentConfigDto.getKeyStorePath());
|
||||||
|
System.setProperty("server.ssl.key-store-password", agentConfigDto.getKeyStorePassword());
|
||||||
|
System.setProperty("server.ssl.key-store-type", "PKCS12");
|
||||||
|
System.setProperty("server.ssl.trust-store", agentConfigDto.getTrustStorePath());
|
||||||
|
System.setProperty("server.ssl.trust-store-password", agentConfigDto.getTrustStorePassword());
|
||||||
|
System.setProperty("server.ssl.trust-store-type", "JKS");
|
||||||
|
}
|
||||||
|
} catch (DatabindException e) {
|
||||||
|
System.out.println("cannot parse a setting file. " + settingFilePath);
|
||||||
|
e.printStackTrace(System.out);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("cannot read a setting file. " + settingFilePath);
|
||||||
|
e.printStackTrace(System.out);
|
||||||
|
}
|
||||||
|
SpringApplication.run(DfxAgentApplication.class, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in new issue