diff --git a/README.md b/README.md
index 927b923..1f10a9f 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,8 @@
**官网: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)**
+在开源运行时社区[OSCR.COM](https://osrc.com)快速运行HertzBeat - [部署流程](https://osrc.com/user/articles/wiki_776513931985080320)
+
## 🎡 介绍
> [HertzBeat赫兹跳动](https://github.com/dromara/hertzbeat) 是由[Dromara](https://dromara.org)孵化,[TanCloud](https://tancloud.cn)开源的一个支持网站,API,PING,端口,数据库,操作系统等监控类型,拥有易用友好的可视化操作界面的开源监控告警项目。
diff --git a/README_EN.md b/README_EN.md
index 7058ad2..9b0d833 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -22,6 +22,8 @@
**Home: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)**
+Running HertzBeat in [OSCR.COM](https://osrc.com) Open Source Runtime Community - [Doc](https://osrc.com/user/articles/wiki_776513931985080320)
+
## 🎡 Introduction
> [HertzBeat](https://github.com/dromara/hertzbeat) is an opensource monitoring and alarm project incubated by [Dromara](https://dromara.org) and open sourced by [TanCloud](https://tancloud.cn), which supports Website, API, PING, Port, Database, OS Monitor etc.
diff --git a/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java b/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java
index 5c8a337..b216548 100644
--- a/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java
+++ b/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java
@@ -11,6 +11,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yaml.snakeyaml.Yaml;
@@ -18,6 +21,7 @@ import org.yaml.snakeyaml.Yaml;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@@ -122,6 +126,8 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
@Override
public void run(String... args) throws Exception {
+ boolean loadFromFile = true;
+ final List inputStreams = new LinkedList<>();
// 读取app定义配置加载到内存中 define/app/*.yml
Yaml yaml = new Yaml();
String classpath = this.getClass().getClassLoader().getResource("").getPath();
@@ -132,37 +138,82 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
defineAppPath = classpath + File.separator + "define" + File.separator + "app";
directory = new File(defineAppPath);
if (!directory.exists() || directory.listFiles() == null) {
- throw new IllegalArgumentException("define app directory not exist: " + defineAppPath);
- }
- }
- log.info("query define path {}", defineAppPath);
- for (File appFile : Objects.requireNonNull(directory.listFiles())) {
- if (appFile.exists()) {
- try (FileInputStream fileInputStream = new FileInputStream(appFile)) {
- Job app = yaml.loadAs(fileInputStream, Job.class);
- appDefines.put(app.getApp().toLowerCase(), app);
- } catch (IOException e) {
- log.error(e.getMessage(), e);
- throw new IOException(e);
+ // load define app yml in jar
+ log.info("load define app yml in internal jar");
+ loadFromFile = false;
+ try {
+ ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+ Resource[] resources = resolver.getResources("classpath:define/app/*.yml");
+ for (Resource resource : resources) {
+ inputStreams.add(resource.getInputStream());
+ }
+ } catch (Exception e) {
+ log.error("define app yml not exist");
+ throw e;
}
}
}
+ if (loadFromFile) {
+ log.info("load define path {}", defineAppPath);
+ for (File appFile : Objects.requireNonNull(directory.listFiles())) {
+ if (appFile.exists()) {
+ try (FileInputStream fileInputStream = new FileInputStream(appFile)) {
+ Job app = yaml.loadAs(fileInputStream, Job.class);
+ appDefines.put(app.getApp().toLowerCase(), app);
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ throw new IOException(e);
+ }
+ }
+ }
+ } else {
+ if (inputStreams.isEmpty()) {
+ throw new IllegalArgumentException("define app directory not exist");
+ } else {
+ inputStreams.forEach(stream -> {
+ try {
+ Job app = yaml.loadAs(stream, Job.class);
+ appDefines.put(app.getApp().toLowerCase(), app);
+ stream.close();
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ });
+ }
+ }
+
// 读取监控参数定义配置加载到数据库中 define/param/*.yml
- String defineParamPath = classpath + File.separator + "define" + File.separator + "param";
- directory = new File(defineParamPath);
- if (!directory.exists() || directory.listFiles() == null) {
- throw new IllegalArgumentException("define param directory not exist: " + defineParamPath);
- }
- for (File appFile : Objects.requireNonNull(directory.listFiles())) {
- if (appFile.exists()) {
- try (FileInputStream fileInputStream = new FileInputStream(appFile)) {
- ParamDefineDto paramDefine = yaml.loadAs(fileInputStream, ParamDefineDto.class);
- paramDefines.put(paramDefine.getApp().toLowerCase(), paramDefine.getParam());
- } catch (IOException e) {
- log.error(e.getMessage(), e);
- throw new IOException(e);
+ if (loadFromFile) {
+ String defineParamPath = classpath + File.separator + "define" + File.separator + "param";
+ directory = new File(defineParamPath);
+ if (!directory.exists() || directory.listFiles() == null) {
+ throw new IllegalArgumentException("define param directory not exist: " + defineParamPath);
+ }
+ for (File appFile : Objects.requireNonNull(directory.listFiles())) {
+ if (appFile.exists()) {
+ try (FileInputStream fileInputStream = new FileInputStream(appFile)) {
+ ParamDefineDto paramDefine = yaml.loadAs(fileInputStream, ParamDefineDto.class);
+ paramDefines.put(paramDefine.getApp().toLowerCase(), paramDefine.getParam());
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ throw new IOException(e);
+ }
}
}
+ } else {
+ try {
+ ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+ Resource[] resources = resolver.getResources("classpath:define/param/*.yml");
+ for (Resource resource : resources) {
+ InputStream stream = resource.getInputStream();
+ ParamDefineDto paramDefine = yaml.loadAs(stream, ParamDefineDto.class);
+ paramDefines.put(paramDefine.getApp().toLowerCase(), paramDefine.getParam());
+ stream.close();
+ }
+ } catch (Exception e) {
+ log.error("define param yml not exist");
+ throw e;
+ }
}
}
}
diff --git a/web-app/package.json b/web-app/package.json
index a18c9d8..b29b6ac 100644
--- a/web-app/package.json
+++ b/web-app/package.json
@@ -1,5 +1,5 @@
{
- "name": "web-app",
+ "name": "hertzbeat-web-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",