[doc,manager,webapp]support deploy with osrc.com

This commit is contained in:
tomsun28
2022-04-19 20:18:01 +08:00
parent 81896f9ba1
commit 0b82096ff7
4 changed files with 81 additions and 26 deletions

View File

@@ -21,6 +21,8 @@
**官网: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)** **官网: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)**
在开源运行时社区[OSCR.COM](https://osrc.com)快速运行HertzBeat - [部署流程](https://osrc.com/user/articles/wiki_776513931985080320)
## 🎡 <font color="green">介绍</font> ## 🎡 <font color="green">介绍</font>
> [HertzBeat赫兹跳动](https://github.com/dromara/hertzbeat) 是由[Dromara](https://dromara.org)孵化,[TanCloud](https://tancloud.cn)开源的一个支持网站APIPING端口数据库操作系统等监控类型拥有易用友好的可视化操作界面的开源监控告警项目。 > [HertzBeat赫兹跳动](https://github.com/dromara/hertzbeat) 是由[Dromara](https://dromara.org)孵化,[TanCloud](https://tancloud.cn)开源的一个支持网站APIPING端口数据库操作系统等监控类型拥有易用友好的可视化操作界面的开源监控告警项目。

View File

@@ -22,6 +22,8 @@
**Home: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)** **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)
## 🎡 <font color="green">Introduction</font> ## 🎡 <font color="green">Introduction</font>
> [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. > [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.

View File

@@ -11,6 +11,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order; 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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
@@ -18,6 +21,7 @@ import org.yaml.snakeyaml.Yaml;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@@ -122,6 +126,8 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
boolean loadFromFile = true;
final List<InputStream> inputStreams = new LinkedList<>();
// 读取app定义配置加载到内存中 define/app/*.yml // 读取app定义配置加载到内存中 define/app/*.yml
Yaml yaml = new Yaml(); Yaml yaml = new Yaml();
String classpath = this.getClass().getClassLoader().getResource("").getPath(); 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"; defineAppPath = classpath + File.separator + "define" + File.separator + "app";
directory = new File(defineAppPath); directory = new File(defineAppPath);
if (!directory.exists() || directory.listFiles() == null) { if (!directory.exists() || directory.listFiles() == null) {
throw new IllegalArgumentException("define app directory not exist: " + defineAppPath); // load define app yml in jar
} log.info("load define app yml in internal jar");
} loadFromFile = false;
log.info("query define path {}", defineAppPath); try {
for (File appFile : Objects.requireNonNull(directory.listFiles())) { ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
if (appFile.exists()) { Resource[] resources = resolver.getResources("classpath:define/app/*.yml");
try (FileInputStream fileInputStream = new FileInputStream(appFile)) { for (Resource resource : resources) {
Job app = yaml.loadAs(fileInputStream, Job.class); inputStreams.add(resource.getInputStream());
appDefines.put(app.getApp().toLowerCase(), app); }
} catch (IOException e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error("define app yml not exist");
throw new IOException(e); 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 // 读取监控参数定义配置加载到数据库中 define/param/*.yml
String defineParamPath = classpath + File.separator + "define" + File.separator + "param"; if (loadFromFile) {
directory = new File(defineParamPath); String defineParamPath = classpath + File.separator + "define" + File.separator + "param";
if (!directory.exists() || directory.listFiles() == null) { directory = new File(defineParamPath);
throw new IllegalArgumentException("define param directory not exist: " + 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()) { for (File appFile : Objects.requireNonNull(directory.listFiles())) {
try (FileInputStream fileInputStream = new FileInputStream(appFile)) { if (appFile.exists()) {
ParamDefineDto paramDefine = yaml.loadAs(fileInputStream, ParamDefineDto.class); try (FileInputStream fileInputStream = new FileInputStream(appFile)) {
paramDefines.put(paramDefine.getApp().toLowerCase(), paramDefine.getParam()); ParamDefineDto paramDefine = yaml.loadAs(fileInputStream, ParamDefineDto.class);
} catch (IOException e) { paramDefines.put(paramDefine.getApp().toLowerCase(), paramDefine.getParam());
log.error(e.getMessage(), e); } catch (IOException e) {
throw new 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;
}
} }
} }
} }

View File

@@ -1,5 +1,5 @@
{ {
"name": "web-app", "name": "hertzbeat-web-app",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",