Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ private void intConfig() {
if (StringUtils.isEmpty(config.getIp())) {
config.setIp(NetUtils.getLocalHost());
}
JobNodeConfigFactory.buildIdentity(config);

if (StringUtils.isEmpty(config.getIdentity())) {
JobNodeConfigFactory.buildIdentity(config);
}

// 初始化一些 db access
MonitorAccessFactory factory = ServiceLoader.load(MonitorAccessFactory.class, config);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.ltsopensource.monitor;

import com.github.ltsopensource.core.commons.file.FileUtils;
import com.github.ltsopensource.core.commons.utils.Assert;
import com.github.ltsopensource.core.commons.utils.StringUtils;
import org.apache.log4j.PropertyConfigurator;

import java.io.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand All @@ -17,21 +17,30 @@ public class MonitorCfgLoader {

public static MonitorCfg load(String confPath) {

String cfgPath = confPath + "/lts-monitor.cfg";
String log4jPath = confPath + "/log4j.properties";

String monitorConfigName = "lts-monitor.cfg";
String cfgPath = confPath + File.separator + monitorConfigName;

// String log4jConfigName = "log4j.properties";
// String log4jPath = confPath + File.separator + log4jConfigName;

Properties conf = new Properties();
File file = new File(cfgPath);
InputStream is = null;

try {
is = new FileInputStream(file);
} catch (FileNotFoundException e) {
throw new CfgException("can not find " + cfgPath);
}
try {
is = MonitorCfgLoader.class.getClassLoader().getResourceAsStream(monitorConfigName);
conf.load(is);
} catch (IOException e) {
e.printStackTrace();
throw new CfgException("Read " + cfgPath + " error.", e);
}finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}

MonitorCfg cfg = new MonitorCfg();
Expand Down Expand Up @@ -68,10 +77,10 @@ public static MonitorCfg load(String confPath) {
throw new CfgException(e);
}

if (FileUtils.exist(log4jPath)) {
// log4j 配置文件路径
PropertyConfigurator.configure(log4jPath);
}
// if (FileUtils.exist(log4jPath)) {
// // log4j 配置文件路径
// PropertyConfigurator.configure(log4jPath);
// }

return cfg;
}
Expand Down