mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-30 10:58:14 +08:00
init 2.10.0
This commit is contained in:
parent
ebeac1f0f3
commit
a82647eccc
18
CHANGELOG.2.10.md
Normal file
18
CHANGELOG.2.10.md
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
## 2.10.0
|
||||
|
||||
### 🐣 新增功能
|
||||
|
||||
1. 【all】外置 `logback` 配置文件
|
||||
|
||||
|
||||
### ❌ 不兼容功能
|
||||
|
||||
1. 【server】取消支持 2.8.0 以下 json 文件转存数据库
|
||||
2. 【all】下架 JDK 管理模块(请使用 DSL 项目模式代替)
|
||||
3. 【all】下架 TOMCAT 管理模块(请使用 DSL 项目模式代替)
|
||||
4. 【all】删除 项目内存监控页面
|
||||
5. 【all】配置文件名称由 `extConfig.yml` 变更为 `application.yml`
|
||||
6. 【all】调整项目打包目录结构
|
||||
7. 【all】取消兼容低版本数据目录文件迁移(调试运行)
|
@ -74,31 +74,7 @@
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<!-- 是否指定项目classpath下的依赖 -->
|
||||
<addClasspath>true</addClasspath>
|
||||
<!-- 指定依赖的时候声明前缀 -->
|
||||
<classpathPrefix>./</classpathPrefix>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<!-- 项目版本号 -->
|
||||
<Jpom-Project-Version>${project.version}</Jpom-Project-Version>
|
||||
<!-- 打包时间 -->
|
||||
<Jpom-Timestamp>${maven.build.timestamp}</Jpom-Timestamp>
|
||||
<Jpom-Type>${project.artifactId}</Jpom-Type>
|
||||
<Implementation-URL>https://gitee.com/dromara/Jpom</Implementation-URL>
|
||||
<Jpom-Min-Version>${jpom-min-version}</Jpom-Min-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
<resources>
|
||||
<!--版权文件,更新日志-->
|
||||
@ -124,6 +100,36 @@
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<!-- 是否指定项目classpath下的依赖 -->
|
||||
<addClasspath>true</addClasspath>
|
||||
<!-- 指定依赖的时候声明前缀 -->
|
||||
<classpathPrefix>./</classpathPrefix>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<!-- 项目版本号 -->
|
||||
<Jpom-Project-Version>${project.version}</Jpom-Project-Version>
|
||||
<!-- 打包时间 -->
|
||||
<Jpom-Timestamp>${maven.build.timestamp}</Jpom-Timestamp>
|
||||
<Jpom-Type>${project.artifactId}</Jpom-Type>
|
||||
<Implementation-URL>https://gitee.com/dromara/Jpom</Implementation-URL>
|
||||
<Jpom-Min-Version>${jpom-min-version}</Jpom-Min-Version>
|
||||
</manifestEntries>
|
||||
<addMavenDescriptor>true</addMavenDescriptor>
|
||||
</archive>
|
||||
<excludes>
|
||||
<exclude>logback.xml</exclude>
|
||||
<exclude>application.yml</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
@ -148,7 +154,7 @@
|
||||
<configuration>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<descriptors>
|
||||
<descriptor>script/release.xml</descriptor>
|
||||
<descriptor>src/main/assembly/release.xml</descriptor>
|
||||
</descriptors>
|
||||
<outputDirectory>target</outputDirectory>
|
||||
</configuration>
|
||||
|
@ -1,83 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Code Technology Studio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
-->
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||
<id>release</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
<format>zip</format>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
|
||||
<fileSets>
|
||||
<!-- 打包Jpom 管理命令文件-->
|
||||
<fileSet>
|
||||
<directory>script/</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>Agent.sh</include>
|
||||
</includes>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>script/</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>Agent.bat</include>
|
||||
</includes>
|
||||
<lineEnding>dos</lineEnding>
|
||||
</fileSet>
|
||||
<!--复制外部配置文件-->
|
||||
<fileSet>
|
||||
<directory>src/main/resources/bin/</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>extConfig.yml</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<!--版权文件-->
|
||||
<fileSet>
|
||||
<directory>../../</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>LICENSE</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<!-- 依赖的 jar 包 copy 到 lib 目录下 -->
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<includes>
|
||||
<include>io.jpom:agent</include>
|
||||
</includes>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
|
||||
</assembly>
|
84
modules/agent/src/main/assembly/release.xml
Normal file
84
modules/agent/src/main/assembly/release.xml
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Code Technology Studio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
-->
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||
<id>release</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
<format>zip</format>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
|
||||
<fileSets>
|
||||
<!-- 打包Jpom 管理命令文件-->
|
||||
<fileSet>
|
||||
<directory>./src/main/bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>Agent.sh</include>
|
||||
</includes>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>./src/main/bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>Agent.bat</include>
|
||||
</includes>
|
||||
<lineEnding>dos</lineEnding>
|
||||
</fileSet>
|
||||
<!--复制外部配置文件-->
|
||||
<fileSet>
|
||||
<directory>./src/main/resources/config_default/</directory>
|
||||
<outputDirectory>/conf</outputDirectory>
|
||||
<includes>
|
||||
<include>logback.xml</include>
|
||||
<include>application.yml</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<!--版权文件-->
|
||||
<fileSet>
|
||||
<directory>../../</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>LICENSE</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<!-- 依赖的 jar 包 copy 到 lib 目录下 -->
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<includes>
|
||||
<include>io.jpom:agent</include>
|
||||
</includes>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
|
||||
</assembly>
|
@ -29,10 +29,12 @@ import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.EnableCommonBoot;
|
||||
import io.jpom.common.JpomAppType;
|
||||
import io.jpom.common.ServerOpenApi;
|
||||
import io.jpom.common.Type;
|
||||
import io.jpom.common.interceptor.AuthorizeInterceptor;
|
||||
import io.jpom.system.init.AutoRegSeverNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
|
||||
@ -45,44 +47,46 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
@SpringBootApplication
|
||||
@ServletComponentScan
|
||||
@EnableCommonBoot
|
||||
@Slf4j
|
||||
@JpomAppType(Type.Agent)
|
||||
public class JpomAgentApplication {
|
||||
|
||||
/**
|
||||
* 启动执行
|
||||
*
|
||||
* @param args 参数
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
long time = SystemClock.now();
|
||||
JpomApplication jpomApplication = new JpomApplication(Type.Agent, JpomAgentApplication.class, args);
|
||||
jpomApplication
|
||||
// 拦截器
|
||||
.addInterceptor(AuthorizeInterceptor.class)
|
||||
// 添加 参数 url 解码
|
||||
// .addHandlerMethodArgumentResolver(UrlDecodeHandlerMethodArgumentResolver.class)
|
||||
.run(args);
|
||||
// 自动向服务端推送
|
||||
autoPushToServer(args);
|
||||
Console.log("Time-consuming to start this time:{}", DateUtil.formatBetween(SystemClock.now() - time, BetweenFormatter.Level.MILLISECOND));
|
||||
}
|
||||
/**
|
||||
* 启动执行
|
||||
*
|
||||
* @param args 参数
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
long time = SystemClock.now();
|
||||
JpomApplication jpomApplication = new JpomApplication(JpomAgentApplication.class);
|
||||
jpomApplication
|
||||
// 拦截器
|
||||
.addInterceptor(AuthorizeInterceptor.class)
|
||||
// 添加 参数 url 解码
|
||||
// .addHandlerMethodArgumentResolver(UrlDecodeHandlerMethodArgumentResolver.class)
|
||||
.run(args);
|
||||
// 自动向服务端推送
|
||||
autoPushToServer(args);
|
||||
log.info("Time-consuming to start this time:{}", DateUtil.formatBetween(SystemClock.now() - time, BetweenFormatter.Level.MILLISECOND));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动推送 插件端信息到服务端
|
||||
*
|
||||
* @param args 参数
|
||||
*/
|
||||
private static void autoPushToServer(String[] args) {
|
||||
int i = ArrayUtil.indexOf(args, ServerOpenApi.PUSH_NODE_KEY);
|
||||
if (i == ArrayUtil.INDEX_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
String arg = ArrayUtil.get(args, i + 1);
|
||||
if (StrUtil.isEmpty(arg)) {
|
||||
Console.error("not found auto-push-to-server url");
|
||||
return;
|
||||
}
|
||||
AutoRegSeverNode.autoPushToServer(arg);
|
||||
}
|
||||
/**
|
||||
* 自动推送 插件端信息到服务端
|
||||
*
|
||||
* @param args 参数
|
||||
*/
|
||||
private static void autoPushToServer(String[] args) {
|
||||
int i = ArrayUtil.indexOf(args, ServerOpenApi.PUSH_NODE_KEY);
|
||||
if (i == ArrayUtil.INDEX_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
String arg = ArrayUtil.get(args, i + 1);
|
||||
if (StrUtil.isEmpty(arg)) {
|
||||
Console.error("not found auto-push-to-server url");
|
||||
return;
|
||||
}
|
||||
AutoRegSeverNode.autoPushToServer(arg);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ package io.jpom.common;
|
||||
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.system.JpomRuntimeException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
|
@ -43,19 +43,16 @@ import io.jpom.common.commander.impl.MacOsProjectCommander;
|
||||
import io.jpom.common.commander.impl.WindowsProjectCommander;
|
||||
import io.jpom.model.RunMode;
|
||||
import io.jpom.model.data.DslYmlDto;
|
||||
import io.jpom.model.data.JdkInfoModel;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
import io.jpom.model.system.NetstatModel;
|
||||
import io.jpom.plugin.IPlugin;
|
||||
import io.jpom.plugin.PluginFactory;
|
||||
import io.jpom.script.DslScriptBuilder;
|
||||
import io.jpom.service.manage.JdkInfoService;
|
||||
import io.jpom.service.manage.ProjectInfoService;
|
||||
import io.jpom.socket.AgentFileTailWatcher;
|
||||
import io.jpom.system.AgentExtConfigBean;
|
||||
import io.jpom.system.JpomRuntimeException;
|
||||
import io.jpom.util.CommandUtil;
|
||||
import io.jpom.util.FileUtils;
|
||||
import io.jpom.util.JvmUtil;
|
||||
import io.jpom.util.ProjectCommanderUtil;
|
||||
import lombok.Lombok;
|
||||
@ -131,19 +128,18 @@ public abstract class AbstractProjectCommander {
|
||||
public abstract String buildJavaCommand(NodeProjectInfoModel nodeProjectInfoModel, NodeProjectInfoModel.JavaCopyItem javaCopyItem);
|
||||
|
||||
protected String getRunJavaPath(NodeProjectInfoModel nodeProjectInfoModel, boolean w) {
|
||||
if (StrUtil.isEmpty(nodeProjectInfoModel.getJdkId())) {
|
||||
// if (StrUtil.isEmpty(nodeProjectInfoModel.getJdkId())) {
|
||||
// return w ? "javaw" : "java";
|
||||
// }
|
||||
//
|
||||
// if (item == null) {
|
||||
return w ? "javaw" : "java";
|
||||
}
|
||||
JdkInfoService bean = SpringUtil.getBean(JdkInfoService.class);
|
||||
JdkInfoModel item = bean.getItem(nodeProjectInfoModel.getJdkId());
|
||||
if (item == null) {
|
||||
return w ? "javaw" : "java";
|
||||
}
|
||||
String jdkJavaPath = FileUtils.getJdkJavaPath(item.getPath(), w);
|
||||
if (jdkJavaPath.contains(StrUtil.SPACE)) {
|
||||
jdkJavaPath = String.format("\"%s\"", jdkJavaPath);
|
||||
}
|
||||
return jdkJavaPath;
|
||||
// }
|
||||
// String jdkJavaPath = FileUtils.getJdkJavaPath(item.getPath(), w);
|
||||
// if (jdkJavaPath.contains(StrUtil.SPACE)) {
|
||||
// jdkJavaPath = String.format("\"%s\"", jdkJavaPath);
|
||||
// }
|
||||
// return jdkJavaPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,126 +1,126 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.common.commander;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import io.jpom.common.commander.impl.LinuxTomcatCommander;
|
||||
import io.jpom.common.commander.impl.WindowsTomcatCommander;
|
||||
import io.jpom.model.data.TomcatInfoModel;
|
||||
import io.jpom.system.JpomRuntimeException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* tomcat命令执行工具类
|
||||
*
|
||||
* @author LF
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class AbstractTomcatCommander {
|
||||
|
||||
private static AbstractTomcatCommander abstractTomcatCommander;
|
||||
|
||||
public static AbstractTomcatCommander getInstance() {
|
||||
if (abstractTomcatCommander != null) {
|
||||
return abstractTomcatCommander;
|
||||
}
|
||||
if (SystemUtil.getOsInfo().isLinux()) {
|
||||
// Linux系统
|
||||
abstractTomcatCommander = new LinuxTomcatCommander();
|
||||
} else if (SystemUtil.getOsInfo().isWindows()) {
|
||||
// Windows系统
|
||||
abstractTomcatCommander = new WindowsTomcatCommander();
|
||||
} else if (SystemUtil.getOsInfo().isMac()) {
|
||||
abstractTomcatCommander = new LinuxTomcatCommander();
|
||||
} else {
|
||||
throw new JpomRuntimeException("不支持的:" + SystemUtil.getOsInfo().getName());
|
||||
}
|
||||
return abstractTomcatCommander;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行tomcat命令
|
||||
*
|
||||
* @param tomcatInfoModel tomcat信息
|
||||
* @param cmd 执行的命令,包括start stop
|
||||
* @return 返回tomcat启动结果
|
||||
*/
|
||||
public abstract String execCmd(TomcatInfoModel tomcatInfoModel, String cmd);
|
||||
|
||||
/**
|
||||
* 检查tomcat状态
|
||||
*
|
||||
* @param tomcatInfoModel tomcat信息
|
||||
* @param cmd 操作命令
|
||||
* @return 状态结果
|
||||
*/
|
||||
protected String getStatus(TomcatInfoModel tomcatInfoModel, String cmd) {
|
||||
String strReturn = "start".equals(cmd) ? "stopped" : "started";
|
||||
int i = 0;
|
||||
while (i < 10) {
|
||||
int result = 0;
|
||||
String url = String.format("http://127.0.0.1:%d/", tomcatInfoModel.getPort());
|
||||
HttpRequest httpRequest = new HttpRequest(url);
|
||||
// 设置超时时间为3秒
|
||||
httpRequest.setConnectionTimeout(3000);
|
||||
try (HttpResponse response = httpRequest.execute()) {
|
||||
result = 1;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
i++;
|
||||
if ("start".equals(cmd) && result == 1) {
|
||||
strReturn = "started";
|
||||
break;
|
||||
}
|
||||
if ("stop".equals(cmd) && result == 0) {
|
||||
strReturn = "stopped";
|
||||
break;
|
||||
}
|
||||
ThreadUtil.sleep(1000);
|
||||
}
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
protected void exec(String command, boolean close) {
|
||||
log.info(command);
|
||||
try {
|
||||
// 执行命令
|
||||
Process process = Runtime.getRuntime().exec(command);
|
||||
process.getInputStream().close();
|
||||
process.getErrorStream().close();
|
||||
process.getOutputStream().close();
|
||||
process.waitFor(5, TimeUnit.SECONDS);
|
||||
if (close) {
|
||||
process.destroy();
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
log.error("tomcat执行名称失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.common.commander;
|
||||
//
|
||||
//import cn.hutool.core.thread.ThreadUtil;
|
||||
//import cn.hutool.http.HttpRequest;
|
||||
//import cn.hutool.http.HttpResponse;
|
||||
//import cn.hutool.system.SystemUtil;
|
||||
//import io.jpom.common.commander.impl.LinuxTomcatCommander;
|
||||
//import io.jpom.common.commander.impl.WindowsTomcatCommander;
|
||||
//import io.jpom.model.data.TomcatInfoModel;
|
||||
//import io.jpom.system.JpomRuntimeException;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//
|
||||
///**
|
||||
// * tomcat命令执行工具类
|
||||
// *
|
||||
// * @author LF
|
||||
// */
|
||||
//@Slf4j
|
||||
//public abstract class AbstractTomcatCommander {
|
||||
//
|
||||
// private static AbstractTomcatCommander abstractTomcatCommander;
|
||||
//
|
||||
// public static AbstractTomcatCommander getInstance() {
|
||||
// if (abstractTomcatCommander != null) {
|
||||
// return abstractTomcatCommander;
|
||||
// }
|
||||
// if (SystemUtil.getOsInfo().isLinux()) {
|
||||
// // Linux系统
|
||||
// abstractTomcatCommander = new LinuxTomcatCommander();
|
||||
// } else if (SystemUtil.getOsInfo().isWindows()) {
|
||||
// // Windows系统
|
||||
// abstractTomcatCommander = new WindowsTomcatCommander();
|
||||
// } else if (SystemUtil.getOsInfo().isMac()) {
|
||||
// abstractTomcatCommander = new LinuxTomcatCommander();
|
||||
// } else {
|
||||
// throw new JpomRuntimeException("不支持的:" + SystemUtil.getOsInfo().getName());
|
||||
// }
|
||||
// return abstractTomcatCommander;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 执行tomcat命令
|
||||
// *
|
||||
// * @param tomcatInfoModel tomcat信息
|
||||
// * @param cmd 执行的命令,包括start stop
|
||||
// * @return 返回tomcat启动结果
|
||||
// */
|
||||
// public abstract String execCmd(TomcatInfoModel tomcatInfoModel, String cmd);
|
||||
//
|
||||
// /**
|
||||
// * 检查tomcat状态
|
||||
// *
|
||||
// * @param tomcatInfoModel tomcat信息
|
||||
// * @param cmd 操作命令
|
||||
// * @return 状态结果
|
||||
// */
|
||||
// protected String getStatus(TomcatInfoModel tomcatInfoModel, String cmd) {
|
||||
// String strReturn = "start".equals(cmd) ? "stopped" : "started";
|
||||
// int i = 0;
|
||||
// while (i < 10) {
|
||||
// int result = 0;
|
||||
// String url = String.format("http://127.0.0.1:%d/", tomcatInfoModel.getPort());
|
||||
// HttpRequest httpRequest = new HttpRequest(url);
|
||||
// // 设置超时时间为3秒
|
||||
// httpRequest.setConnectionTimeout(3000);
|
||||
// try (HttpResponse response = httpRequest.execute()) {
|
||||
// result = 1;
|
||||
// } catch (Exception ignored) {
|
||||
// }
|
||||
//
|
||||
// i++;
|
||||
// if ("start".equals(cmd) && result == 1) {
|
||||
// strReturn = "started";
|
||||
// break;
|
||||
// }
|
||||
// if ("stop".equals(cmd) && result == 0) {
|
||||
// strReturn = "stopped";
|
||||
// break;
|
||||
// }
|
||||
// ThreadUtil.sleep(1000);
|
||||
// }
|
||||
// return strReturn;
|
||||
// }
|
||||
//
|
||||
// protected void exec(String command, boolean close) {
|
||||
// log.info(command);
|
||||
// try {
|
||||
// // 执行命令
|
||||
// Process process = Runtime.getRuntime().exec(command);
|
||||
// process.getInputStream().close();
|
||||
// process.getErrorStream().close();
|
||||
// process.getOutputStream().close();
|
||||
// process.waitFor(5, TimeUnit.SECONDS);
|
||||
// if (close) {
|
||||
// process.destroy();
|
||||
// }
|
||||
// } catch (IOException | InterruptedException e) {
|
||||
// log.error("tomcat执行名称失败", e);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -1,80 +1,80 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.common.commander.impl;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.text.StrSplitter;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.jpom.common.commander.AbstractTomcatCommander;
|
||||
import io.jpom.model.data.TomcatInfoModel;
|
||||
import io.jpom.util.CommandUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* tomcat的linux管理命令
|
||||
*
|
||||
* @author LF
|
||||
*/
|
||||
public class LinuxTomcatCommander extends AbstractTomcatCommander {
|
||||
|
||||
@Override
|
||||
public String execCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
|
||||
String tomcatPath = tomcatInfoModel.pathAndCheck();
|
||||
if (StrUtil.isBlank(tomcatPath)) {
|
||||
return "tomcat path blank";
|
||||
}
|
||||
String command = null;
|
||||
if ("stop".equals(cmd)) {
|
||||
String setPidCmd = CommandUtil.execSystemCommand("jps -mv");
|
||||
List<String> list = StrSplitter.splitTrim(setPidCmd, StrUtil.LF, true);
|
||||
for (String item : list) {
|
||||
//路径格式转换
|
||||
String msg = FileUtil.normalize(item + StrUtil.SLASH);
|
||||
//判断集合中元素是否包含指定Tomcat路径
|
||||
boolean w = msg.contains(tomcatInfoModel.getPath());
|
||||
if (w) {
|
||||
//截取TomcatPid
|
||||
if (msg.indexOf(" ") > 1) {
|
||||
String tmPid = msg.substring(0, msg.indexOf(" "));
|
||||
//判断截取的PID是否为纯数字
|
||||
if (NumberUtil.isInteger(tmPid)) {
|
||||
command = String.format("kill -9 %s", tmPid);
|
||||
exec(command, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
command = String.format("/bin/sh -c %s/bin/startup.sh", tomcatPath);
|
||||
//
|
||||
exec(command, false);
|
||||
}
|
||||
if (StrUtil.isBlank(tomcatPath)) {
|
||||
return "tomcat path blank";
|
||||
}
|
||||
// 查询操作结果并返回
|
||||
return getStatus(tomcatInfoModel, cmd);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.common.commander.impl;
|
||||
//
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.core.text.StrSplitter;
|
||||
//import cn.hutool.core.util.NumberUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import io.jpom.common.commander.AbstractTomcatCommander;
|
||||
//import io.jpom.model.data.TomcatInfoModel;
|
||||
//import io.jpom.util.CommandUtil;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * tomcat的linux管理命令
|
||||
// *
|
||||
// * @author LF
|
||||
// */
|
||||
//public class LinuxTomcatCommander extends AbstractTomcatCommander {
|
||||
//
|
||||
// @Override
|
||||
// public String execCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
|
||||
// String tomcatPath = tomcatInfoModel.pathAndCheck();
|
||||
// if (StrUtil.isBlank(tomcatPath)) {
|
||||
// return "tomcat path blank";
|
||||
// }
|
||||
// String command = null;
|
||||
// if ("stop".equals(cmd)) {
|
||||
// String setPidCmd = CommandUtil.execSystemCommand("jps -mv");
|
||||
// List<String> list = StrSplitter.splitTrim(setPidCmd, StrUtil.LF, true);
|
||||
// for (String item : list) {
|
||||
// //路径格式转换
|
||||
// String msg = FileUtil.normalize(item + StrUtil.SLASH);
|
||||
// //判断集合中元素是否包含指定Tomcat路径
|
||||
// boolean w = msg.contains(tomcatInfoModel.getPath());
|
||||
// if (w) {
|
||||
// //截取TomcatPid
|
||||
// if (msg.indexOf(" ") > 1) {
|
||||
// String tmPid = msg.substring(0, msg.indexOf(" "));
|
||||
// //判断截取的PID是否为纯数字
|
||||
// if (NumberUtil.isInteger(tmPid)) {
|
||||
// command = String.format("kill -9 %s", tmPid);
|
||||
// exec(command, false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// command = String.format("/bin/sh -c %s/bin/startup.sh", tomcatPath);
|
||||
// //
|
||||
// exec(command, false);
|
||||
// }
|
||||
// if (StrUtil.isBlank(tomcatPath)) {
|
||||
// return "tomcat path blank";
|
||||
// }
|
||||
// // 查询操作结果并返回
|
||||
// return getStatus(tomcatInfoModel, cmd);
|
||||
// }
|
||||
//}
|
||||
|
@ -1,90 +1,90 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.common.commander.impl;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.text.StrSplitter;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.jpom.common.commander.AbstractTomcatCommander;
|
||||
import io.jpom.model.data.TomcatInfoModel;
|
||||
import io.jpom.util.CommandUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* tomcat的Windows管理命令
|
||||
*
|
||||
* @author LF
|
||||
*/
|
||||
public class WindowsTomcatCommander extends AbstractTomcatCommander {
|
||||
|
||||
/**
|
||||
* windows下执行tomcat命令
|
||||
*
|
||||
* @param tomcatInfoModel tomcat信息
|
||||
* @param cmd 执行的命令,包括start stop
|
||||
* @return 返回tomcat启动结果
|
||||
*/
|
||||
@Override
|
||||
public String execCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
|
||||
String tomcatPath = tomcatInfoModel.pathAndCheck();
|
||||
//截取盘符
|
||||
String dcPath = null;
|
||||
if (tomcatPath != null && tomcatPath.indexOf(StrUtil.SLASH) > 1) {
|
||||
dcPath = tomcatPath.substring(0, tomcatPath.indexOf(StrUtil.SLASH));
|
||||
}
|
||||
String command = null;
|
||||
if (StrUtil.isBlank(tomcatPath)) {
|
||||
return "tomcat path blank";
|
||||
}
|
||||
|
||||
if ("stop".equals(cmd)) {
|
||||
String setPidCmd = CommandUtil.execSystemCommand("jps -mv");
|
||||
List<String> list = StrSplitter.splitTrim(setPidCmd, StrUtil.LF, true);
|
||||
for (String item : list) {
|
||||
//window下路径格式转换
|
||||
String msg = FileUtil.normalize(item + StrUtil.SLASH);
|
||||
//判断集合中元素是否包含指定Tomcat路径
|
||||
boolean w = msg.contains(tomcatInfoModel.getPath());
|
||||
if (w) {
|
||||
//截取TomcatPid
|
||||
if (msg.indexOf(" ") > 1) {
|
||||
String tmPid = msg.substring(0, msg.indexOf(" "));
|
||||
//判断截取的PID是否为纯数字
|
||||
if (NumberUtil.isInteger(tmPid)) {
|
||||
command = String.format("taskkill /F /PID %s", tmPid);
|
||||
exec(command, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
command = String.format("cmd /k %s && cd %s/bin && start startup.bat", dcPath, tomcatPath);
|
||||
exec(command, true);
|
||||
}
|
||||
|
||||
// 查询操作结果并返回
|
||||
return getStatus(tomcatInfoModel, cmd);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.common.commander.impl;
|
||||
//
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.core.text.StrSplitter;
|
||||
//import cn.hutool.core.util.NumberUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import io.jpom.common.commander.AbstractTomcatCommander;
|
||||
//import io.jpom.model.data.TomcatInfoModel;
|
||||
//import io.jpom.util.CommandUtil;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * tomcat的Windows管理命令
|
||||
// *
|
||||
// * @author LF
|
||||
// */
|
||||
//public class WindowsTomcatCommander extends AbstractTomcatCommander {
|
||||
//
|
||||
// /**
|
||||
// * windows下执行tomcat命令
|
||||
// *
|
||||
// * @param tomcatInfoModel tomcat信息
|
||||
// * @param cmd 执行的命令,包括start stop
|
||||
// * @return 返回tomcat启动结果
|
||||
// */
|
||||
// @Override
|
||||
// public String execCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
|
||||
// String tomcatPath = tomcatInfoModel.pathAndCheck();
|
||||
// //截取盘符
|
||||
// String dcPath = null;
|
||||
// if (tomcatPath != null && tomcatPath.indexOf(StrUtil.SLASH) > 1) {
|
||||
// dcPath = tomcatPath.substring(0, tomcatPath.indexOf(StrUtil.SLASH));
|
||||
// }
|
||||
// String command = null;
|
||||
// if (StrUtil.isBlank(tomcatPath)) {
|
||||
// return "tomcat path blank";
|
||||
// }
|
||||
//
|
||||
// if ("stop".equals(cmd)) {
|
||||
// String setPidCmd = CommandUtil.execSystemCommand("jps -mv");
|
||||
// List<String> list = StrSplitter.splitTrim(setPidCmd, StrUtil.LF, true);
|
||||
// for (String item : list) {
|
||||
// //window下路径格式转换
|
||||
// String msg = FileUtil.normalize(item + StrUtil.SLASH);
|
||||
// //判断集合中元素是否包含指定Tomcat路径
|
||||
// boolean w = msg.contains(tomcatInfoModel.getPath());
|
||||
// if (w) {
|
||||
// //截取TomcatPid
|
||||
// if (msg.indexOf(" ") > 1) {
|
||||
// String tmPid = msg.substring(0, msg.indexOf(" "));
|
||||
// //判断截取的PID是否为纯数字
|
||||
// if (NumberUtil.isInteger(tmPid)) {
|
||||
// command = String.format("taskkill /F /PID %s", tmPid);
|
||||
// exec(command, true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// command = String.format("cmd /k %s && cd %s/bin && start startup.bat", dcPath, tomcatPath);
|
||||
// exec(command, true);
|
||||
// }
|
||||
//
|
||||
// // 查询操作结果并返回
|
||||
// return getStatus(tomcatInfoModel, cmd);
|
||||
// }
|
||||
//}
|
||||
|
@ -24,9 +24,9 @@ package io.jpom.common.interceptor;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.interceptor.BaseInterceptor;
|
||||
import cn.jiangzeyin.common.interceptor.InterceptorPattens;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.system.AgentAuthorize;
|
||||
import io.jpom.system.ConfigBean;
|
||||
import org.springframework.http.MediaType;
|
||||
|
@ -25,10 +25,10 @@ package io.jpom.controller;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.RemoteVersion;
|
||||
import io.jpom.common.interceptor.NotAuthorize;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
|
@ -26,10 +26,10 @@ import cn.hutool.cache.impl.CacheObj;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.SystemClock;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.controller.base.AbstractController;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.AbstractSystemCommander;
|
||||
import io.jpom.model.system.ProcessModel;
|
||||
import io.jpom.system.TopManager;
|
||||
|
@ -1,99 +1,99 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.controller.manage;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.model.data.JdkInfoModel;
|
||||
import io.jpom.service.manage.JdkInfoService;
|
||||
import io.jpom.util.FileUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/11/1
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/manage/jdk/")
|
||||
public class JdkListController extends BaseAgentController {
|
||||
|
||||
@Resource
|
||||
private JdkInfoService jdkInfoService;
|
||||
|
||||
@RequestMapping(value = "list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String list() {
|
||||
List<JdkInfoModel> list = jdkInfoService.list();
|
||||
return JsonMessage.getString(200, "", list);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String update(JdkInfoModel model) {
|
||||
String path = model.getPath();
|
||||
if (StrUtil.isEmpty(path)) {
|
||||
return JsonMessage.getString(400, "请填写jdk路径");
|
||||
}
|
||||
String newPath = FileUtil.normalize(path);
|
||||
File file = FileUtil.file(newPath);
|
||||
//去除bin
|
||||
if ("bin".equals(file.getName())) {
|
||||
newPath = file.getParentFile().getAbsolutePath();
|
||||
}
|
||||
if (!FileUtils.isJdkPath(newPath)) {
|
||||
return JsonMessage.getString(400, "路径错误,该路径不是jdk路径");
|
||||
}
|
||||
model.setPath(newPath);
|
||||
String id = model.getId();
|
||||
String jdkVersion = FileUtils.getJdkVersion(newPath);
|
||||
model.setVersion(jdkVersion);
|
||||
String name = model.getName();
|
||||
if (StrUtil.isEmpty(name)) {
|
||||
model.setName(jdkVersion);
|
||||
}
|
||||
if (StrUtil.isEmpty(id)) {
|
||||
model.setId(IdUtil.fastSimpleUUID());
|
||||
jdkInfoService.addItem(model);
|
||||
return JsonMessage.getString(200, "添加成功");
|
||||
}
|
||||
jdkInfoService.updateItem(model);
|
||||
return JsonMessage.getString(200, "修改成功");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String delete(String id) {
|
||||
if (StrUtil.isEmpty(id)) {
|
||||
return JsonMessage.getString(400, "删除失败");
|
||||
}
|
||||
jdkInfoService.deleteItem(id);
|
||||
return JsonMessage.getString(200, "删除成功");
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.controller.manage;
|
||||
//
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.core.util.IdUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import io.jpom.common.JsonMessage;
|
||||
//import io.jpom.common.BaseAgentController;
|
||||
//import io.jpom.model.data.JdkInfoModel;
|
||||
//import io.jpom.service.manage.JdkInfoService;
|
||||
//import io.jpom.util.FileUtils;
|
||||
//import org.springframework.http.MediaType;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.io.File;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * @author bwcx_jzy
|
||||
// * @since 2019/11/1
|
||||
// */
|
||||
//@RestController
|
||||
//@RequestMapping(value = "/manage/jdk/")
|
||||
//public class JdkListController extends BaseAgentController {
|
||||
//
|
||||
// @Resource
|
||||
// private JdkInfoService jdkInfoService;
|
||||
//
|
||||
// @RequestMapping(value = "list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String list() {
|
||||
// List<JdkInfoModel> list = jdkInfoService.list();
|
||||
// return JsonMessage.getString(200, "", list);
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String update(JdkInfoModel model) {
|
||||
// String path = model.getPath();
|
||||
// if (StrUtil.isEmpty(path)) {
|
||||
// return JsonMessage.getString(400, "请填写jdk路径");
|
||||
// }
|
||||
// String newPath = FileUtil.normalize(path);
|
||||
// File file = FileUtil.file(newPath);
|
||||
// //去除bin
|
||||
// if ("bin".equals(file.getName())) {
|
||||
// newPath = file.getParentFile().getAbsolutePath();
|
||||
// }
|
||||
// if (!FileUtils.isJdkPath(newPath)) {
|
||||
// return JsonMessage.getString(400, "路径错误,该路径不是jdk路径");
|
||||
// }
|
||||
// model.setPath(newPath);
|
||||
// String id = model.getId();
|
||||
// String jdkVersion = FileUtils.getJdkVersion(newPath);
|
||||
// model.setVersion(jdkVersion);
|
||||
// String name = model.getName();
|
||||
// if (StrUtil.isEmpty(name)) {
|
||||
// model.setName(jdkVersion);
|
||||
// }
|
||||
// if (StrUtil.isEmpty(id)) {
|
||||
// model.setId(IdUtil.fastSimpleUUID());
|
||||
// jdkInfoService.addItem(model);
|
||||
// return JsonMessage.getString(200, "添加成功");
|
||||
// }
|
||||
// jdkInfoService.updateItem(model);
|
||||
// return JsonMessage.getString(200, "修改成功");
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String delete(String id) {
|
||||
// if (StrUtil.isEmpty(id)) {
|
||||
// return JsonMessage.getString(400, "删除失败");
|
||||
// }
|
||||
// jdkInfoService.deleteItem(id);
|
||||
// return JsonMessage.getString(200, "删除成功");
|
||||
// }
|
||||
//}
|
||||
|
@ -29,17 +29,15 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.RegexPool;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.Const;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.AbstractProjectCommander;
|
||||
import io.jpom.model.RunMode;
|
||||
import io.jpom.model.data.DslYmlDto;
|
||||
import io.jpom.model.data.JdkInfoModel;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
import io.jpom.service.WhitelistDirectoryService;
|
||||
import io.jpom.service.manage.JdkInfoService;
|
||||
import io.jpom.system.ConfigBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -65,12 +63,9 @@ import java.util.List;
|
||||
public class ManageEditProjectController extends BaseAgentController {
|
||||
|
||||
private final WhitelistDirectoryService whitelistDirectoryService;
|
||||
private final JdkInfoService jdkInfoService;
|
||||
|
||||
public ManageEditProjectController(WhitelistDirectoryService whitelistDirectoryService,
|
||||
JdkInfoService jdkInfoService) {
|
||||
public ManageEditProjectController(WhitelistDirectoryService whitelistDirectoryService) {
|
||||
this.whitelistDirectoryService = whitelistDirectoryService;
|
||||
this.jdkInfoService = jdkInfoService;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,10 +200,7 @@ public class ManageEditProjectController extends BaseAgentController {
|
||||
Assert.state(!id.contains(StrUtil.SPACE) && !allLib.contains(StrUtil.SPACE), "项目Id、项目路径不能包含空格");
|
||||
|
||||
String jdkId = projectInfo.getJdkId();
|
||||
if (StrUtil.isNotEmpty(jdkId)) {
|
||||
JdkInfoModel item = jdkInfoService.getItem(jdkId);
|
||||
Assert.notNull(item, "jdk 信息错误");
|
||||
}
|
||||
|
||||
// 判断 yml
|
||||
this.checkDslYml(projectInfo);
|
||||
//
|
||||
|
@ -27,10 +27,10 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
import io.jpom.script.ProjectFileBackupUtil;
|
||||
import io.jpom.util.CommandUtil;
|
||||
|
@ -33,11 +33,11 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.controller.multipart.MultipartFileBuilder;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.AbstractProjectCommander;
|
||||
import io.jpom.common.commander.CommandOpResult;
|
||||
import io.jpom.controller.manage.vo.DiffFileVo;
|
||||
|
@ -23,8 +23,8 @@
|
||||
package io.jpom.controller.manage;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.AbstractProjectCommander;
|
||||
import io.jpom.model.RunMode;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
|
@ -23,8 +23,8 @@
|
||||
package io.jpom.controller.manage;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.common.BaseJpomController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.data.ProjectRecoverModel;
|
||||
import io.jpom.service.manage.ProjectRecoverService;
|
||||
import org.springframework.http.MediaType;
|
||||
|
@ -23,12 +23,12 @@
|
||||
package io.jpom.controller.manage;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.AbstractProjectCommander;
|
||||
import io.jpom.common.commander.CommandOpResult;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
|
@ -24,9 +24,9 @@ package io.jpom.controller.manage.log;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.AbstractProjectCommander;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
import io.jpom.util.FileUtils;
|
||||
|
@ -1,252 +1,252 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.controller.monitor;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.commander.AbstractProjectCommander;
|
||||
import io.jpom.common.commander.AbstractSystemCommander;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
import io.jpom.model.system.NetstatModel;
|
||||
import io.jpom.model.system.ProcessModel;
|
||||
import io.jpom.system.AgentConfigBean;
|
||||
import io.jpom.util.CommandUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 内存查看
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/manage/")
|
||||
@Slf4j
|
||||
public class InternalController extends BaseAgentController {
|
||||
|
||||
/**
|
||||
* 获取内存信息
|
||||
*
|
||||
* @param tag 程序运行标识
|
||||
* @return json
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@RequestMapping(value = "internal_data", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getInternal(String tag, String copyId) throws Exception {
|
||||
String tagId = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
|
||||
int pid = AbstractProjectCommander.getInstance().getPid(tagId);
|
||||
if (pid <= 0) {
|
||||
return JsonMessage.getString(400, "");
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
ProcessModel item = AbstractSystemCommander.getInstance().getPidInfo(pid);
|
||||
jsonObject.put("process", item);
|
||||
//JSONObject beanMem = getBeanMem(tagId);
|
||||
//jsonObject.put("beanMem", beanMem);
|
||||
//获取端口信息
|
||||
List<NetstatModel> netstatModels = AbstractProjectCommander.getInstance().listNetstat(pid, false);
|
||||
jsonObject.put("netstat", netstatModels);
|
||||
return JsonMessage.getString(200, "", jsonObject);
|
||||
// return JsonMessage.getString(404, "功能已经下架");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询监控线程列表
|
||||
*
|
||||
* @param tag 程序运行标识
|
||||
* @return json
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@RequestMapping(value = "threadInfos", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getThreadInfos(String tag, String copyId) throws Exception {
|
||||
// int limit = getParameterInt("limit", 10);
|
||||
// int page = getParameterInt("page", 1);
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.controller.monitor;
|
||||
//
|
||||
// ThreadMXBean bean = JvmUtil.getThreadMXBean(ProjectInfoModel.JavaCopyItem.getTagId(tag, copyId));
|
||||
// if (bean == null) {
|
||||
// return JsonMessage.getString(400, "未获取到对应信息");
|
||||
// }
|
||||
// //启用线程争用监视
|
||||
// bean.setThreadContentionMonitoringEnabled(true);
|
||||
// ThreadInfo[] threadInfos = bean.dumpAllThreads(false, false);
|
||||
// if (threadInfos == null || threadInfos.length <= 0) {
|
||||
// return JsonMessage.getString(404, "没有获取到任何线程");
|
||||
// }
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.extra.servlet.ServletUtil;
|
||||
//import io.jpom.common.JsonMessage;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import io.jpom.common.BaseAgentController;
|
||||
//import io.jpom.common.commander.AbstractProjectCommander;
|
||||
//import io.jpom.common.commander.AbstractSystemCommander;
|
||||
//import io.jpom.model.data.NodeProjectInfoModel;
|
||||
//import io.jpom.model.system.NetstatModel;
|
||||
//import io.jpom.model.system.ProcessModel;
|
||||
//import io.jpom.system.AgentConfigBean;
|
||||
//import io.jpom.util.CommandUtil;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.http.MediaType;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.io.File;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 内存查看
|
||||
// *
|
||||
// * @author Administrator
|
||||
// */
|
||||
//@RestController
|
||||
//@RequestMapping(value = "/manage/")
|
||||
//@Slf4j
|
||||
//public class InternalController extends BaseAgentController {
|
||||
//
|
||||
// JSONArray array = new JSONArray();
|
||||
// int index = PageUtil.getStart(page, limit);
|
||||
// int len = limit + index;
|
||||
// int length = threadInfos.length;
|
||||
// if (len > length) {
|
||||
// len = length;
|
||||
// }
|
||||
// for (int i = index; i < len; i++) {
|
||||
// ThreadInfo threadInfo = threadInfos[i];
|
||||
// Thread.State threadState = threadInfo.getThreadState();
|
||||
// JSONObject object = new JSONObject();
|
||||
// object.put("id", threadInfo.getThreadId());
|
||||
// object.put("name", threadInfo.getThreadName());
|
||||
// object.put("status", threadState);
|
||||
// object.put("waitedCount", threadInfo.getWaitedCount());
|
||||
// object.put("waitedTime", threadInfo.getWaitedTime());
|
||||
// object.put("blockedCount", threadInfo.getBlockedCount());
|
||||
// object.put("blockedTime", threadInfo.getBlockedTime());
|
||||
// object.put("isInNative", threadInfo.isInNative());
|
||||
// object.put("isSuspended", threadInfo.isSuspended());
|
||||
// array.add(object);
|
||||
// }
|
||||
// JSONObject object = new JSONObject();
|
||||
// object.put("count", length);
|
||||
// object.put("data", array);
|
||||
// return JsonMessage.getString(200, "", object);
|
||||
return JsonMessage.getString(404, "功能已经下架");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 获取jvm内存
|
||||
// * 获取内存信息
|
||||
// *
|
||||
// * @param tag tag
|
||||
// * @return JSONObject
|
||||
// * @param tag 程序运行标识
|
||||
// * @return json
|
||||
// * @throws Exception 异常
|
||||
// */
|
||||
// private JSONObject getBeanMem(String tag) {
|
||||
// @RequestMapping(value = "internal_data", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String getInternal(String tag, String copyId) throws Exception {
|
||||
// String tagId = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
|
||||
// int pid = AbstractProjectCommander.getInstance().getPid(tagId);
|
||||
// if (pid <= 0) {
|
||||
// return JsonMessage.getString(400, "");
|
||||
// }
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// ProcessModel item = AbstractSystemCommander.getInstance().getPidInfo(pid);
|
||||
// jsonObject.put("process", item);
|
||||
// //JSONObject beanMem = getBeanMem(tagId);
|
||||
// //jsonObject.put("beanMem", beanMem);
|
||||
// //获取端口信息
|
||||
// List<NetstatModel> netstatModels = AbstractProjectCommander.getInstance().listNetstat(pid, false);
|
||||
// jsonObject.put("netstat", netstatModels);
|
||||
// return JsonMessage.getString(200, "", jsonObject);
|
||||
//// return JsonMessage.getString(404, "功能已经下架");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询监控线程列表
|
||||
// *
|
||||
// * @param tag 程序运行标识
|
||||
// * @return json
|
||||
// * @throws Exception 异常
|
||||
// */
|
||||
// @RequestMapping(value = "threadInfos", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String getThreadInfos(String tag, String copyId) throws Exception {
|
||||
//// int limit = getParameterInt("limit", 10);
|
||||
//// int page = getParameterInt("page", 1);
|
||||
////
|
||||
//// ThreadMXBean bean = JvmUtil.getThreadMXBean(ProjectInfoModel.JavaCopyItem.getTagId(tag, copyId));
|
||||
//// if (bean == null) {
|
||||
//// return JsonMessage.getString(400, "未获取到对应信息");
|
||||
//// }
|
||||
//// //启用线程争用监视
|
||||
//// bean.setThreadContentionMonitoringEnabled(true);
|
||||
//// ThreadInfo[] threadInfos = bean.dumpAllThreads(false, false);
|
||||
//// if (threadInfos == null || threadInfos.length <= 0) {
|
||||
//// return JsonMessage.getString(404, "没有获取到任何线程");
|
||||
//// }
|
||||
////
|
||||
//// JSONArray array = new JSONArray();
|
||||
//// int index = PageUtil.getStart(page, limit);
|
||||
//// int len = limit + index;
|
||||
//// int length = threadInfos.length;
|
||||
//// if (len > length) {
|
||||
//// len = length;
|
||||
//// }
|
||||
//// for (int i = index; i < len; i++) {
|
||||
//// ThreadInfo threadInfo = threadInfos[i];
|
||||
//// Thread.State threadState = threadInfo.getThreadState();
|
||||
//// JSONObject object = new JSONObject();
|
||||
//// object.put("id", threadInfo.getThreadId());
|
||||
//// object.put("name", threadInfo.getThreadName());
|
||||
//// object.put("status", threadState);
|
||||
//// object.put("waitedCount", threadInfo.getWaitedCount());
|
||||
//// object.put("waitedTime", threadInfo.getWaitedTime());
|
||||
//// object.put("blockedCount", threadInfo.getBlockedCount());
|
||||
//// object.put("blockedTime", threadInfo.getBlockedTime());
|
||||
//// object.put("isInNative", threadInfo.isInNative());
|
||||
//// object.put("isSuspended", threadInfo.isSuspended());
|
||||
//// array.add(object);
|
||||
//// }
|
||||
//// JSONObject object = new JSONObject();
|
||||
//// object.put("count", length);
|
||||
//// object.put("data", array);
|
||||
//// return JsonMessage.getString(200, "", object);
|
||||
// return JsonMessage.getString(404, "功能已经下架");
|
||||
// }
|
||||
//
|
||||
//// /**
|
||||
//// * 获取jvm内存
|
||||
//// *
|
||||
//// * @param tag tag
|
||||
//// * @return JSONObject
|
||||
//// */
|
||||
//// private JSONObject getBeanMem(String tag) {
|
||||
//// try {
|
||||
//// MemoryMXBean bean = JvmUtil.getMemoryMXBean(tag);
|
||||
//// if (bean == null) {
|
||||
//// return null;
|
||||
//// }
|
||||
//// JSONObject jsonObject = new JSONObject();
|
||||
//// jsonObject.put("mount", bean.getObjectPendingFinalizationCount());
|
||||
//// //堆内存
|
||||
//// MemoryUsage memory = bean.getHeapMemoryUsage();
|
||||
//// //非堆内存
|
||||
//// MemoryUsage nonHeapMemoryUsage = bean.getNonHeapMemoryUsage();
|
||||
//// long used = memory.getUsed();
|
||||
//// long max = memory.getMax();
|
||||
//// //未定义
|
||||
//// if (-1 == max) {
|
||||
//// max = memory.getCommitted();
|
||||
//// }
|
||||
//// //计算使用内存占最大内存的百分比
|
||||
//// double v = new BigDecimal(used).divide(new BigDecimal(max), 2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
|
||||
//// jsonObject.put("heapUsed", FileUtil.readableFileSize(used));
|
||||
//// jsonObject.put("heapProportion", String.format("%.2f", v) + "%");
|
||||
//// jsonObject.put("heapCommitted", FileUtil.readableFileSize(memory.getCommitted()));
|
||||
//// long nonUsed = nonHeapMemoryUsage.getUsed();
|
||||
//// long nonMax = nonHeapMemoryUsage.getMax();
|
||||
//// long nonCommitted = nonHeapMemoryUsage.getCommitted();
|
||||
//// if (-1 == nonMax) {
|
||||
//// nonMax = nonCommitted;
|
||||
//// }
|
||||
//// jsonObject.put("nonHeapUsed", FileUtil.readableFileSize(nonUsed));
|
||||
//// double proportion = new BigDecimal(nonUsed).divide(new BigDecimal(nonMax), 2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
|
||||
//// jsonObject.put("nonHeapProportion", String.format("%.2f", proportion) + "%");
|
||||
//// jsonObject.put("nonHeapCommitted", FileUtil.readableFileSize(nonCommitted));
|
||||
//// return jsonObject;
|
||||
//// } catch (Exception e) {
|
||||
//// log.error(e.getMessage(), e);
|
||||
//// }
|
||||
//// return null;
|
||||
//// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 导出堆栈信息
|
||||
// *
|
||||
// * @param tag 程序运行标识
|
||||
// * @return json
|
||||
// */
|
||||
// @RequestMapping(value = "internal_stack", method = RequestMethod.GET)
|
||||
// @ResponseBody
|
||||
// public String stack(String tag, String copyId) {
|
||||
// tag = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
|
||||
// //
|
||||
// String fileName = AgentConfigBean.getInstance().getTempPathName() + StrUtil.SLASH + tag + "_java_cpu.txt";
|
||||
// fileName = FileUtil.normalize(fileName);
|
||||
// try {
|
||||
// MemoryMXBean bean = JvmUtil.getMemoryMXBean(tag);
|
||||
// if (bean == null) {
|
||||
// return null;
|
||||
// int pid = AbstractProjectCommander.getInstance().getPid(tag);
|
||||
// if (pid <= 0) {
|
||||
// return JsonMessage.getString(400, "未运行");
|
||||
// }
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("mount", bean.getObjectPendingFinalizationCount());
|
||||
// //堆内存
|
||||
// MemoryUsage memory = bean.getHeapMemoryUsage();
|
||||
// //非堆内存
|
||||
// MemoryUsage nonHeapMemoryUsage = bean.getNonHeapMemoryUsage();
|
||||
// long used = memory.getUsed();
|
||||
// long max = memory.getMax();
|
||||
// //未定义
|
||||
// if (-1 == max) {
|
||||
// max = memory.getCommitted();
|
||||
// }
|
||||
// //计算使用内存占最大内存的百分比
|
||||
// double v = new BigDecimal(used).divide(new BigDecimal(max), 2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
|
||||
// jsonObject.put("heapUsed", FileUtil.readableFileSize(used));
|
||||
// jsonObject.put("heapProportion", String.format("%.2f", v) + "%");
|
||||
// jsonObject.put("heapCommitted", FileUtil.readableFileSize(memory.getCommitted()));
|
||||
// long nonUsed = nonHeapMemoryUsage.getUsed();
|
||||
// long nonMax = nonHeapMemoryUsage.getMax();
|
||||
// long nonCommitted = nonHeapMemoryUsage.getCommitted();
|
||||
// if (-1 == nonMax) {
|
||||
// nonMax = nonCommitted;
|
||||
// }
|
||||
// jsonObject.put("nonHeapUsed", FileUtil.readableFileSize(nonUsed));
|
||||
// double proportion = new BigDecimal(nonUsed).divide(new BigDecimal(nonMax), 2, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
|
||||
// jsonObject.put("nonHeapProportion", String.format("%.2f", proportion) + "%");
|
||||
// jsonObject.put("nonHeapCommitted", FileUtil.readableFileSize(nonCommitted));
|
||||
// return jsonObject;
|
||||
// String command = String.format("jstack -F %s >> %s ", pid, fileName);
|
||||
// CommandUtil.execSystemCommand(command);
|
||||
// downLoad(getResponse(), fileName);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
//// getResponse().sendRedirect("internal?tag=" + tag);
|
||||
// }
|
||||
// return null;
|
||||
// return JsonMessage.getString(200, "");
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 导出堆栈信息
|
||||
*
|
||||
* @param tag 程序运行标识
|
||||
* @return json
|
||||
*/
|
||||
@RequestMapping(value = "internal_stack", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String stack(String tag, String copyId) {
|
||||
tag = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
|
||||
//
|
||||
String fileName = AgentConfigBean.getInstance().getTempPathName() + StrUtil.SLASH + tag + "_java_cpu.txt";
|
||||
fileName = FileUtil.normalize(fileName);
|
||||
try {
|
||||
int pid = AbstractProjectCommander.getInstance().getPid(tag);
|
||||
if (pid <= 0) {
|
||||
return JsonMessage.getString(400, "未运行");
|
||||
}
|
||||
String command = String.format("jstack -F %s >> %s ", pid, fileName);
|
||||
CommandUtil.execSystemCommand(command);
|
||||
downLoad(getResponse(), fileName);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
// getResponse().sendRedirect("internal?tag=" + tag);
|
||||
}
|
||||
return JsonMessage.getString(200, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出内存信息
|
||||
*
|
||||
* @param tag 程序运行标识
|
||||
* @return json
|
||||
*/
|
||||
@RequestMapping(value = "internal_ram", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public String ram(String tag, String copyId) {
|
||||
tag = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
|
||||
//
|
||||
String fileName = AgentConfigBean.getInstance().getTempPathName() + StrUtil.SLASH + tag + "_java_ram.txt";
|
||||
fileName = FileUtil.normalize(fileName);
|
||||
try {
|
||||
int pid = AbstractProjectCommander.getInstance().getPid(tag);
|
||||
if (pid <= 0) {
|
||||
return JsonMessage.getString(400, "未运行");
|
||||
}
|
||||
String command = String.format("jmap -histo:live %s >> %s", pid, fileName);
|
||||
CommandUtil.execSystemCommand(command);
|
||||
downLoad(getResponse(), fileName);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
// getResponse().sendRedirect("internal?tag=" + tag);
|
||||
}
|
||||
return JsonMessage.getString(200, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param response response
|
||||
* @param fileName 文件名字
|
||||
*/
|
||||
private void downLoad(HttpServletResponse response, String fileName) {
|
||||
//获取项目根路径
|
||||
File file = new File(fileName);
|
||||
ServletUtil.write(response, file);
|
||||
FileUtil.del(file);
|
||||
}
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 导出内存信息
|
||||
// *
|
||||
// * @param tag 程序运行标识
|
||||
// * @return json
|
||||
// */
|
||||
// @RequestMapping(value = "internal_ram", method = RequestMethod.GET)
|
||||
// @ResponseBody
|
||||
// public String ram(String tag, String copyId) {
|
||||
// tag = NodeProjectInfoModel.JavaCopyItem.getTagId(tag, copyId);
|
||||
// //
|
||||
// String fileName = AgentConfigBean.getInstance().getTempPathName() + StrUtil.SLASH + tag + "_java_ram.txt";
|
||||
// fileName = FileUtil.normalize(fileName);
|
||||
// try {
|
||||
// int pid = AbstractProjectCommander.getInstance().getPid(tag);
|
||||
// if (pid <= 0) {
|
||||
// return JsonMessage.getString(400, "未运行");
|
||||
// }
|
||||
// String command = String.format("jmap -histo:live %s >> %s", pid, fileName);
|
||||
// CommandUtil.execSystemCommand(command);
|
||||
// downLoad(getResponse(), fileName);
|
||||
// } catch (Exception e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
//// getResponse().sendRedirect("internal?tag=" + tag);
|
||||
// }
|
||||
// return JsonMessage.getString(200, "");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 下载文件
|
||||
// *
|
||||
// * @param response response
|
||||
// * @param fileName 文件名字
|
||||
// */
|
||||
// private void downLoad(HttpServletResponse response, String fileName) {
|
||||
// //获取项目根路径
|
||||
// File file = new File(fileName);
|
||||
// ServletUtil.write(response, file);
|
||||
// FileUtil.del(file);
|
||||
// }
|
||||
//}
|
||||
|
@ -30,13 +30,13 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.cron.pattern.CronPattern;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
import cn.jiangzeyin.controller.multipart.MultipartFileBuilder;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.data.NodeScriptExecLogModel;
|
||||
import io.jpom.model.data.NodeScriptModel;
|
||||
import io.jpom.script.ScriptProcessBuilder;
|
||||
|
@ -23,12 +23,12 @@
|
||||
package io.jpom.controller.system;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.AbstractProjectCommander;
|
||||
import io.jpom.cron.CronUtils;
|
||||
import io.jpom.model.system.WorkspaceEnvVarModel;
|
||||
|
@ -23,9 +23,9 @@
|
||||
package io.jpom.controller.system;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.system.WorkspaceEnvVarModel;
|
||||
import io.jpom.service.system.AgentWorkspaceEnvVarService;
|
||||
import org.springframework.http.MediaType;
|
||||
|
@ -27,10 +27,10 @@ import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.controller.multipart.MultipartFileBuilder;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.data.CertModel;
|
||||
import io.jpom.service.WhitelistDirectoryService;
|
||||
import io.jpom.service.system.CertService;
|
||||
|
@ -24,14 +24,13 @@ package io.jpom.controller.system;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.socket.AgentFileTailWatcher;
|
||||
import io.jpom.system.WebAopLog;
|
||||
import io.jpom.system.LogbackConfig;
|
||||
import io.jpom.util.LayuiTreeUtil;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.Assert;
|
||||
@ -56,8 +55,7 @@ public class LogManageController extends BaseAgentController {
|
||||
|
||||
@RequestMapping(value = "log_data.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String logData() {
|
||||
WebAopLog webAopLog = SpringUtil.getBean(WebAopLog.class);
|
||||
JSONArray data = LayuiTreeUtil.getTreeData(webAopLog.getPropertyValue());
|
||||
JSONArray data = LayuiTreeUtil.getTreeData(LogbackConfig.getPath());
|
||||
return JsonMessage.getString(200, "", data);
|
||||
}
|
||||
|
||||
@ -65,8 +63,7 @@ public class LogManageController extends BaseAgentController {
|
||||
@RequestMapping(value = "log_del.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public String logData(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "path错误") String path) {
|
||||
WebAopLog webAopLog = SpringUtil.getBean(WebAopLog.class);
|
||||
File file = FileUtil.file(webAopLog.getPropertyValue(), path);
|
||||
File file = FileUtil.file(LogbackConfig.getPath(), path);
|
||||
// 判断修改时间
|
||||
long modified = file.lastModified();
|
||||
Assert.state(System.currentTimeMillis() - modified > TimeUnit.DAYS.toMillis(1), "不能删除近一天相关的日志(文件修改时间)");
|
||||
@ -81,8 +78,7 @@ public class LogManageController extends BaseAgentController {
|
||||
@RequestMapping(value = "log_download", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public void logDownload(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "path错误") String path) {
|
||||
WebAopLog webAopLog = SpringUtil.getBean(WebAopLog.class);
|
||||
File file = FileUtil.file(webAopLog.getPropertyValue(), path);
|
||||
File file = FileUtil.file(LogbackConfig.getPath(), path);
|
||||
if (file.isFile()) {
|
||||
ServletUtil.write(getResponse(), file);
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import cn.hutool.core.text.StrSplitter;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@ -38,6 +37,7 @@ import com.github.odiszapc.nginxparser.NgxConfig;
|
||||
import com.github.odiszapc.nginxparser.NgxEntry;
|
||||
import com.github.odiszapc.nginxparser.NgxParam;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.AbstractSystemCommander;
|
||||
import io.jpom.model.data.AgentWhitelist;
|
||||
import io.jpom.service.WhitelistDirectoryService;
|
||||
|
@ -28,12 +28,12 @@ import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.Const;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.system.ExtConfigBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.env.YamlPropertySourceLoader;
|
||||
|
@ -29,7 +29,6 @@ import cn.hutool.core.lang.Tuple;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.controller.multipart.MultipartFileBuilder;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.common.*;
|
||||
|
@ -27,8 +27,8 @@ import cn.hutool.core.lang.RegexPool;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.common.BaseJpomController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.data.AgentWhitelist;
|
||||
import io.jpom.service.WhitelistDirectoryService;
|
||||
import io.jpom.system.AgentExtConfigBean;
|
||||
|
@ -1,142 +1,142 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.controller.tomcat;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.model.data.TomcatInfoModel;
|
||||
import io.jpom.service.manage.TomcatEditService;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* tomcat 编辑
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/7/21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/tomcat/")
|
||||
public class TomcatEditController extends BaseAgentController {
|
||||
@Resource
|
||||
private TomcatEditService tomcatEditService;
|
||||
|
||||
|
||||
/**
|
||||
* 列出所有的tomcat
|
||||
*
|
||||
* @return Tomcat列表
|
||||
*/
|
||||
@RequestMapping(value = "list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String list() {
|
||||
// 查询tomcat列表
|
||||
List<TomcatInfoModel> tomcatInfoModels = tomcatEditService.list();
|
||||
return JsonMessage.getString(200, "查询成功", tomcatInfoModels);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Id查询Tomcat信息
|
||||
*
|
||||
* @param id Tomcat的主键
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "getItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getItem(String id) {
|
||||
// 查询tomcat列表
|
||||
return JsonMessage.getString(200, "查询成功", tomcatEditService.getItem(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加Tomcat
|
||||
*
|
||||
* @param tomcatInfoModel Tomcat信息
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String add(TomcatInfoModel tomcatInfoModel) {
|
||||
// 根据Tomcat名称查询tomcat是否已经存在
|
||||
String name = tomcatInfoModel.getName();
|
||||
TomcatInfoModel tomcatInfoModelTemp = tomcatEditService.getItemByName(name);
|
||||
if (tomcatInfoModelTemp != null) {
|
||||
return JsonMessage.getString(401, "名称已经存在,请使用其他名称!");
|
||||
}
|
||||
tomcatInfoModel.setId(SecureUtil.md5(DateUtil.now()));
|
||||
tomcatInfoModel.setCreator(getUserName());
|
||||
|
||||
// 设置tomcat路径,去除多余的符号
|
||||
tomcatInfoModel.setPath(FileUtil.normalize(tomcatInfoModel.getPath()));
|
||||
Objects.requireNonNull(tomcatInfoModel.pathAndCheck());
|
||||
tomcatEditService.addItem(tomcatInfoModel);
|
||||
tomcatInfoModel.initTomcat();
|
||||
return JsonMessage.getString(200, "保存成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改Tomcat信息
|
||||
*
|
||||
* @param tomcatInfoModel Tomcat信息
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String update(TomcatInfoModel tomcatInfoModel) {
|
||||
// 根据Tomcat名称查询tomcat是否已经存在
|
||||
String name = tomcatInfoModel.getName();
|
||||
TomcatInfoModel tomcatInfoModelTemp = tomcatEditService.getItemByName(name);
|
||||
if (tomcatInfoModelTemp != null && !tomcatInfoModelTemp.getId().equals(tomcatInfoModel.getId())) {
|
||||
return JsonMessage.getString(401, "名称已经存在,请使用其他名称!");
|
||||
}
|
||||
|
||||
tomcatInfoModel.setModifyUser(getUserName());
|
||||
// 设置tomcat路径,去除多余的符号
|
||||
tomcatInfoModel.setPath(FileUtil.normalize(tomcatInfoModel.getPath()));
|
||||
Objects.requireNonNull(tomcatInfoModel.pathAndCheck());
|
||||
tomcatEditService.updateItem(tomcatInfoModel);
|
||||
tomcatInfoModel.initTomcat();
|
||||
return JsonMessage.getString(200, "修改成功");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除tomcat
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String delete(String id) {
|
||||
tomcatEditService.deleteItem(id);
|
||||
return JsonMessage.getString(200, "删除成功");
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.controller.tomcat;
|
||||
//
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.crypto.SecureUtil;
|
||||
//import io.jpom.common.JsonMessage;
|
||||
//import io.jpom.common.BaseAgentController;
|
||||
//import io.jpom.model.data.TomcatInfoModel;
|
||||
//import io.jpom.service.manage.TomcatEditService;
|
||||
//import org.springframework.http.MediaType;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.util.List;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * tomcat 编辑
|
||||
// *
|
||||
// * @author bwcx_jzy
|
||||
// * @since 2019/7/21
|
||||
// */
|
||||
//@RestController
|
||||
//@RequestMapping(value = "/tomcat/")
|
||||
//public class TomcatEditController extends BaseAgentController {
|
||||
// @Resource
|
||||
// private TomcatEditService tomcatEditService;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 列出所有的tomcat
|
||||
// *
|
||||
// * @return Tomcat列表
|
||||
// */
|
||||
// @RequestMapping(value = "list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String list() {
|
||||
// // 查询tomcat列表
|
||||
// List<TomcatInfoModel> tomcatInfoModels = tomcatEditService.list();
|
||||
// return JsonMessage.getString(200, "查询成功", tomcatInfoModels);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据Id查询Tomcat信息
|
||||
// *
|
||||
// * @param id Tomcat的主键
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "getItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String getItem(String id) {
|
||||
// // 查询tomcat列表
|
||||
// return JsonMessage.getString(200, "查询成功", tomcatEditService.getItem(id));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 添加Tomcat
|
||||
// *
|
||||
// * @param tomcatInfoModel Tomcat信息
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String add(TomcatInfoModel tomcatInfoModel) {
|
||||
// // 根据Tomcat名称查询tomcat是否已经存在
|
||||
// String name = tomcatInfoModel.getName();
|
||||
// TomcatInfoModel tomcatInfoModelTemp = tomcatEditService.getItemByName(name);
|
||||
// if (tomcatInfoModelTemp != null) {
|
||||
// return JsonMessage.getString(401, "名称已经存在,请使用其他名称!");
|
||||
// }
|
||||
// tomcatInfoModel.setId(SecureUtil.md5(DateUtil.now()));
|
||||
// tomcatInfoModel.setCreator(getUserName());
|
||||
//
|
||||
// // 设置tomcat路径,去除多余的符号
|
||||
// tomcatInfoModel.setPath(FileUtil.normalize(tomcatInfoModel.getPath()));
|
||||
// Objects.requireNonNull(tomcatInfoModel.pathAndCheck());
|
||||
// tomcatEditService.addItem(tomcatInfoModel);
|
||||
// tomcatInfoModel.initTomcat();
|
||||
// return JsonMessage.getString(200, "保存成功");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 修改Tomcat信息
|
||||
// *
|
||||
// * @param tomcatInfoModel Tomcat信息
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String update(TomcatInfoModel tomcatInfoModel) {
|
||||
// // 根据Tomcat名称查询tomcat是否已经存在
|
||||
// String name = tomcatInfoModel.getName();
|
||||
// TomcatInfoModel tomcatInfoModelTemp = tomcatEditService.getItemByName(name);
|
||||
// if (tomcatInfoModelTemp != null && !tomcatInfoModelTemp.getId().equals(tomcatInfoModel.getId())) {
|
||||
// return JsonMessage.getString(401, "名称已经存在,请使用其他名称!");
|
||||
// }
|
||||
//
|
||||
// tomcatInfoModel.setModifyUser(getUserName());
|
||||
// // 设置tomcat路径,去除多余的符号
|
||||
// tomcatInfoModel.setPath(FileUtil.normalize(tomcatInfoModel.getPath()));
|
||||
// Objects.requireNonNull(tomcatInfoModel.pathAndCheck());
|
||||
// tomcatEditService.updateItem(tomcatInfoModel);
|
||||
// tomcatInfoModel.initTomcat();
|
||||
// return JsonMessage.getString(200, "修改成功");
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 删除tomcat
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String delete(String id) {
|
||||
// tomcatEditService.deleteItem(id);
|
||||
// return JsonMessage.getString(200, "删除成功");
|
||||
// }
|
||||
//}
|
||||
|
@ -1,360 +1,360 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.controller.tomcat;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
import cn.jiangzeyin.controller.multipart.MultipartFileBuilder;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseAgentController;
|
||||
import io.jpom.common.commander.AbstractTomcatCommander;
|
||||
import io.jpom.model.data.TomcatInfoModel;
|
||||
import io.jpom.service.manage.TomcatEditService;
|
||||
import io.jpom.service.manage.TomcatManageService;
|
||||
import io.jpom.socket.AgentFileTailWatcher;
|
||||
import io.jpom.util.LayuiTreeUtil;
|
||||
import io.jpom.util.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author lf
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/tomcat/")
|
||||
@Slf4j
|
||||
public class TomcatManageController extends BaseAgentController {
|
||||
|
||||
@Resource
|
||||
private TomcatEditService tomcatEditService;
|
||||
@Resource
|
||||
private TomcatManageService tomcatManageService;
|
||||
|
||||
/**
|
||||
* 列出所有的tomcat项目列表
|
||||
*
|
||||
* @param id 项目id
|
||||
* @return Tomcat下的项目列表
|
||||
*/
|
||||
@RequestMapping(value = "getTomcatProjectList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getTomcatProjectList(String id) {
|
||||
JSONArray array = tomcatManageService.getTomcatProjectList(id);
|
||||
return JsonMessage.getString(200, "查询成功", array);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询tomcat状态
|
||||
*
|
||||
* @param id tomcat的id
|
||||
* @return tomcat运行状态
|
||||
*/
|
||||
@RequestMapping(value = "getTomcatStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getStatus(String id) {
|
||||
return JsonMessage.getString(200, "查询成功", tomcatManageService.getTomcatStatus(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 启动tomcat
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "start", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String start(String id) {
|
||||
// 查询tomcat信息
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
|
||||
String result = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "start");
|
||||
String msg = "启动成功";
|
||||
if ("stopped".equals(result)) {
|
||||
msg = "启动失败";
|
||||
}
|
||||
return JsonMessage.getString(200, msg, result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除tomcat
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "stop", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String stop(String id) {
|
||||
// 查询tomcat信息
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
|
||||
String result = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "stop");
|
||||
String msg = "停止成功";
|
||||
if ("started".equals(result)) {
|
||||
msg = "停止失败";
|
||||
}
|
||||
return JsonMessage.getString(200, msg, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启tomcat
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "restart", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String restart(String id) {
|
||||
// 查询tomcat信息
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
|
||||
String stopResult = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "stop");
|
||||
String startResult = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "start");
|
||||
return JsonMessage.getString(200, StrUtil.format("重启成功 {} {}", stopResult, startResult));
|
||||
}
|
||||
|
||||
/**
|
||||
* tomcat项目管理
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @param path 项目路径
|
||||
* @param op 执行的操作
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "tomcatProjectManage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String tomcatProjectManage(String id, String path,
|
||||
@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "操作项不对") String op) {
|
||||
|
||||
TomcatOp tomcatOp = TomcatOp.valueOf(op);
|
||||
return tomcatManageService.tomcatProjectManage(id, path, tomcatOp).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目文件列表
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @param path 项目路径
|
||||
* @return 文件列表
|
||||
*/
|
||||
@RequestMapping(value = "getFileList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getFileList(String id, String path) {
|
||||
// 查询项目路径
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
if (tomcatInfoModel == null) {
|
||||
return JsonMessage.getString(500, "查询失败:项目不存在");
|
||||
}
|
||||
if (StrUtil.isEmptyOrUndefined(path)) {
|
||||
return JsonMessage.getString(500, "path value error");
|
||||
}
|
||||
String appBasePath = tomcatInfoModel.getAppBase();
|
||||
File fileDir = FileUtil.file(appBasePath, FileUtil.normalize(path));
|
||||
if (!fileDir.exists()) {
|
||||
return JsonMessage.getString(500, "目录不存在");
|
||||
}
|
||||
File[] filesAll = fileDir.listFiles();
|
||||
if (filesAll == null) {
|
||||
return JsonMessage.getString(500, "目录是空");
|
||||
}
|
||||
|
||||
// JSONArray arrayFile = FileUtils.parseInfo(filesAll, false, appBasePath);
|
||||
JSONArray arrayFile = new JSONArray();
|
||||
JSONArray arrayDir = new JSONArray();
|
||||
for (File file : filesAll) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String parentPath = StringUtil.delStartPath(file, appBasePath, false);
|
||||
jsonObject.put("parentPath", parentPath);
|
||||
jsonObject.put("filename", file.getName());
|
||||
long mTime = file.lastModified();
|
||||
jsonObject.put("modifyTimeLong", mTime);
|
||||
jsonObject.put("modifyTime", DateUtil.date(mTime).toString());
|
||||
|
||||
if (file.isDirectory()) {
|
||||
jsonObject.put("isDirectory", true);
|
||||
long sizeFile = FileUtil.size(file);
|
||||
jsonObject.put("fileSize", FileUtil.readableFileSize(sizeFile));
|
||||
arrayDir.add(jsonObject);
|
||||
} else {
|
||||
jsonObject.put("fileSize", FileUtil.readableFileSize(file.length()));
|
||||
arrayFile.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
JSONArray resultArray = new JSONArray();
|
||||
resultArray.addAll(arrayDir);
|
||||
resultArray.addAll(arrayFile);
|
||||
return JsonMessage.getString(200, "查询成功", resultArray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @param path 文件路径
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "upload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String upload(String id, String path) {
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
|
||||
MultipartFileBuilder multipartFileBuilder = createMultipart()
|
||||
.addFieldName("file");
|
||||
|
||||
File dir = new File(tomcatInfoModel.getAppBase().concat(FileUtil.normalize(path)));
|
||||
|
||||
multipartFileBuilder.setSavePath(dir.getAbsolutePath())
|
||||
.setUseOriginalFilename(true);
|
||||
// 保存
|
||||
try {
|
||||
multipartFileBuilder.save();
|
||||
} catch (IOException e) {
|
||||
return JsonMessage.getString(500, "上传异常");
|
||||
}
|
||||
|
||||
return JsonMessage.getString(200, "上传成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传war文件
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "uploadWar", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String uploadWar(String id) {
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
|
||||
MultipartFileBuilder multipartFileBuilder = createMultipart()
|
||||
.addFieldName("file");
|
||||
|
||||
File dir = new File(tomcatInfoModel.getAppBase());
|
||||
|
||||
multipartFileBuilder.setSavePath(dir.getAbsolutePath())
|
||||
.setUseOriginalFilename(true);
|
||||
// 保存
|
||||
try {
|
||||
multipartFileBuilder.save();
|
||||
} catch (IOException e) {
|
||||
return JsonMessage.getString(500, "上传异常");
|
||||
}
|
||||
|
||||
return JsonMessage.getString(200, "上传成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @param filename 文件名
|
||||
* @param path tomcat路径
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "deleteFile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String deleteFile(String id, String path, String filename) {
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
if (tomcatInfoModel == null) {
|
||||
return JsonMessage.getString(500, "tomcat不存在");
|
||||
}
|
||||
File file;
|
||||
if ("_tomcat_log".equals(path)) {
|
||||
//删除日志文件
|
||||
file = FileUtil.file(tomcatInfoModel.getPath(), "logs", filename);
|
||||
// 判断修改时间
|
||||
long modified = file.lastModified();
|
||||
if (System.currentTimeMillis() - modified < TimeUnit.DAYS.toMillis(1)) {
|
||||
return JsonMessage.getString(405, "不能删除当天的日志");
|
||||
}
|
||||
// 判断最后修改日期
|
||||
AgentFileTailWatcher.offlineFile(file);
|
||||
} else {
|
||||
file = FileUtil.file(tomcatInfoModel.getAppBase(), path, filename);
|
||||
}
|
||||
if (file.exists()) {
|
||||
if (file.delete()) {
|
||||
return JsonMessage.getString(200, "删除成功");
|
||||
} else {
|
||||
return JsonMessage.getString(500, "删除失败");
|
||||
}
|
||||
} else {
|
||||
return JsonMessage.getString(404, "文件不存在");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @param filename 文件名
|
||||
* @param path tomcat路径
|
||||
* @return 操作结果
|
||||
*/
|
||||
@RequestMapping(value = "download", method = RequestMethod.GET)
|
||||
public String download(String id, String path, String filename) {
|
||||
filename = FileUtil.normalize(filename);
|
||||
path = FileUtil.normalize(path);
|
||||
try {
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
File file;
|
||||
//下载日志文件
|
||||
if ("_tomcat_log".equals(path)) {
|
||||
file = FileUtil.file(tomcatInfoModel.getPath(), "logs", filename);
|
||||
} else {
|
||||
file = FileUtil.file(tomcatInfoModel.getAppBase(), path, filename);
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
return "暂不支持下载文件夹";
|
||||
}
|
||||
ServletUtil.write(getResponse(), file);
|
||||
} catch (Exception e) {
|
||||
log.error("下载文件异常", e);
|
||||
}
|
||||
return "下载失败。请刷新页面后重试";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取tomcat 日志列表
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @return json
|
||||
*/
|
||||
@RequestMapping(value = "logList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String logList(String id) {
|
||||
TomcatInfoModel item = tomcatEditService.getItem(id);
|
||||
if (item == null) {
|
||||
return JsonMessage.getString(300, "没有对应数据");
|
||||
}
|
||||
JSONArray jsonArray = LayuiTreeUtil.getTreeData(FileUtil.file(item.pathAndCheck(), "logs").getAbsolutePath());
|
||||
return JsonMessage.getString(200, "", jsonArray);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.controller.tomcat;
|
||||
//
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.extra.servlet.ServletUtil;
|
||||
//import io.jpom.common.JsonMessage;
|
||||
//import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
//import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
//import cn.jiangzeyin.controller.multipart.MultipartFileBuilder;
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import io.jpom.common.BaseAgentController;
|
||||
//import io.jpom.common.commander.AbstractTomcatCommander;
|
||||
//import io.jpom.model.data.TomcatInfoModel;
|
||||
//import io.jpom.service.manage.TomcatEditService;
|
||||
//import io.jpom.service.manage.TomcatManageService;
|
||||
//import io.jpom.socket.AgentFileTailWatcher;
|
||||
//import io.jpom.util.LayuiTreeUtil;
|
||||
//import io.jpom.util.StringUtil;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.http.MediaType;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.io.File;
|
||||
//import java.io.IOException;
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//
|
||||
///**
|
||||
// * @author lf
|
||||
// */
|
||||
//@RestController
|
||||
//@RequestMapping(value = "/tomcat/")
|
||||
//@Slf4j
|
||||
//public class TomcatManageController extends BaseAgentController {
|
||||
//
|
||||
// @Resource
|
||||
// private TomcatEditService tomcatEditService;
|
||||
// @Resource
|
||||
// private TomcatManageService tomcatManageService;
|
||||
//
|
||||
// /**
|
||||
// * 列出所有的tomcat项目列表
|
||||
// *
|
||||
// * @param id 项目id
|
||||
// * @return Tomcat下的项目列表
|
||||
// */
|
||||
// @RequestMapping(value = "getTomcatProjectList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String getTomcatProjectList(String id) {
|
||||
// JSONArray array = tomcatManageService.getTomcatProjectList(id);
|
||||
// return JsonMessage.getString(200, "查询成功", array);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询tomcat状态
|
||||
// *
|
||||
// * @param id tomcat的id
|
||||
// * @return tomcat运行状态
|
||||
// */
|
||||
// @RequestMapping(value = "getTomcatStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String getStatus(String id) {
|
||||
// return JsonMessage.getString(200, "查询成功", tomcatManageService.getTomcatStatus(id));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 启动tomcat
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "start", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String start(String id) {
|
||||
// // 查询tomcat信息
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
//
|
||||
// String result = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "start");
|
||||
// String msg = "启动成功";
|
||||
// if ("stopped".equals(result)) {
|
||||
// msg = "启动失败";
|
||||
// }
|
||||
// return JsonMessage.getString(200, msg, result);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 删除tomcat
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "stop", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String stop(String id) {
|
||||
// // 查询tomcat信息
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
//
|
||||
// String result = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "stop");
|
||||
// String msg = "停止成功";
|
||||
// if ("started".equals(result)) {
|
||||
// msg = "停止失败";
|
||||
// }
|
||||
// return JsonMessage.getString(200, msg, result);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 重启tomcat
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "restart", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String restart(String id) {
|
||||
// // 查询tomcat信息
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
//
|
||||
// String stopResult = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "stop");
|
||||
// String startResult = AbstractTomcatCommander.getInstance().execCmd(tomcatInfoModel, "start");
|
||||
// return JsonMessage.getString(200, StrUtil.format("重启成功 {} {}", stopResult, startResult));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * tomcat项目管理
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @param path 项目路径
|
||||
// * @param op 执行的操作
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "tomcatProjectManage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String tomcatProjectManage(String id, String path,
|
||||
// @ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "操作项不对") String op) {
|
||||
//
|
||||
// TomcatOp tomcatOp = TomcatOp.valueOf(op);
|
||||
// return tomcatManageService.tomcatProjectManage(id, path, tomcatOp).toString();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取项目文件列表
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @param path 项目路径
|
||||
// * @return 文件列表
|
||||
// */
|
||||
// @RequestMapping(value = "getFileList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String getFileList(String id, String path) {
|
||||
// // 查询项目路径
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
// if (tomcatInfoModel == null) {
|
||||
// return JsonMessage.getString(500, "查询失败:项目不存在");
|
||||
// }
|
||||
// if (StrUtil.isEmptyOrUndefined(path)) {
|
||||
// return JsonMessage.getString(500, "path value error");
|
||||
// }
|
||||
// String appBasePath = tomcatInfoModel.getAppBase();
|
||||
// File fileDir = FileUtil.file(appBasePath, FileUtil.normalize(path));
|
||||
// if (!fileDir.exists()) {
|
||||
// return JsonMessage.getString(500, "目录不存在");
|
||||
// }
|
||||
// File[] filesAll = fileDir.listFiles();
|
||||
// if (filesAll == null) {
|
||||
// return JsonMessage.getString(500, "目录是空");
|
||||
// }
|
||||
//
|
||||
// // JSONArray arrayFile = FileUtils.parseInfo(filesAll, false, appBasePath);
|
||||
// JSONArray arrayFile = new JSONArray();
|
||||
// JSONArray arrayDir = new JSONArray();
|
||||
// for (File file : filesAll) {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// String parentPath = StringUtil.delStartPath(file, appBasePath, false);
|
||||
// jsonObject.put("parentPath", parentPath);
|
||||
// jsonObject.put("filename", file.getName());
|
||||
// long mTime = file.lastModified();
|
||||
// jsonObject.put("modifyTimeLong", mTime);
|
||||
// jsonObject.put("modifyTime", DateUtil.date(mTime).toString());
|
||||
//
|
||||
// if (file.isDirectory()) {
|
||||
// jsonObject.put("isDirectory", true);
|
||||
// long sizeFile = FileUtil.size(file);
|
||||
// jsonObject.put("fileSize", FileUtil.readableFileSize(sizeFile));
|
||||
// arrayDir.add(jsonObject);
|
||||
// } else {
|
||||
// jsonObject.put("fileSize", FileUtil.readableFileSize(file.length()));
|
||||
// arrayFile.add(jsonObject);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// JSONArray resultArray = new JSONArray();
|
||||
// resultArray.addAll(arrayDir);
|
||||
// resultArray.addAll(arrayFile);
|
||||
// return JsonMessage.getString(200, "查询成功", resultArray);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 上传文件
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @param path 文件路径
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "upload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String upload(String id, String path) {
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
//
|
||||
// MultipartFileBuilder multipartFileBuilder = createMultipart()
|
||||
// .addFieldName("file");
|
||||
//
|
||||
// File dir = new File(tomcatInfoModel.getAppBase().concat(FileUtil.normalize(path)));
|
||||
//
|
||||
// multipartFileBuilder.setSavePath(dir.getAbsolutePath())
|
||||
// .setUseOriginalFilename(true);
|
||||
// // 保存
|
||||
// try {
|
||||
// multipartFileBuilder.save();
|
||||
// } catch (IOException e) {
|
||||
// return JsonMessage.getString(500, "上传异常");
|
||||
// }
|
||||
//
|
||||
// return JsonMessage.getString(200, "上传成功");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 上传war文件
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "uploadWar", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String uploadWar(String id) {
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
//
|
||||
// MultipartFileBuilder multipartFileBuilder = createMultipart()
|
||||
// .addFieldName("file");
|
||||
//
|
||||
// File dir = new File(tomcatInfoModel.getAppBase());
|
||||
//
|
||||
// multipartFileBuilder.setSavePath(dir.getAbsolutePath())
|
||||
// .setUseOriginalFilename(true);
|
||||
// // 保存
|
||||
// try {
|
||||
// multipartFileBuilder.save();
|
||||
// } catch (IOException e) {
|
||||
// return JsonMessage.getString(500, "上传异常");
|
||||
// }
|
||||
//
|
||||
// return JsonMessage.getString(200, "上传成功");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 删除文件
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @param filename 文件名
|
||||
// * @param path tomcat路径
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "deleteFile", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String deleteFile(String id, String path, String filename) {
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
// if (tomcatInfoModel == null) {
|
||||
// return JsonMessage.getString(500, "tomcat不存在");
|
||||
// }
|
||||
// File file;
|
||||
// if ("_tomcat_log".equals(path)) {
|
||||
// //删除日志文件
|
||||
// file = FileUtil.file(tomcatInfoModel.getPath(), "logs", filename);
|
||||
// // 判断修改时间
|
||||
// long modified = file.lastModified();
|
||||
// if (System.currentTimeMillis() - modified < TimeUnit.DAYS.toMillis(1)) {
|
||||
// return JsonMessage.getString(405, "不能删除当天的日志");
|
||||
// }
|
||||
// // 判断最后修改日期
|
||||
// AgentFileTailWatcher.offlineFile(file);
|
||||
// } else {
|
||||
// file = FileUtil.file(tomcatInfoModel.getAppBase(), path, filename);
|
||||
// }
|
||||
// if (file.exists()) {
|
||||
// if (file.delete()) {
|
||||
// return JsonMessage.getString(200, "删除成功");
|
||||
// } else {
|
||||
// return JsonMessage.getString(500, "删除失败");
|
||||
// }
|
||||
// } else {
|
||||
// return JsonMessage.getString(404, "文件不存在");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 下载文件
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @param filename 文件名
|
||||
// * @param path tomcat路径
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// @RequestMapping(value = "download", method = RequestMethod.GET)
|
||||
// public String download(String id, String path, String filename) {
|
||||
// filename = FileUtil.normalize(filename);
|
||||
// path = FileUtil.normalize(path);
|
||||
// try {
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
// File file;
|
||||
// //下载日志文件
|
||||
// if ("_tomcat_log".equals(path)) {
|
||||
// file = FileUtil.file(tomcatInfoModel.getPath(), "logs", filename);
|
||||
// } else {
|
||||
// file = FileUtil.file(tomcatInfoModel.getAppBase(), path, filename);
|
||||
// }
|
||||
// if (file.isDirectory()) {
|
||||
// return "暂不支持下载文件夹";
|
||||
// }
|
||||
// ServletUtil.write(getResponse(), file);
|
||||
// } catch (Exception e) {
|
||||
// log.error("下载文件异常", e);
|
||||
// }
|
||||
// return "下载失败。请刷新页面后重试";
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取tomcat 日志列表
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @return json
|
||||
// */
|
||||
// @RequestMapping(value = "logList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
// public String logList(String id) {
|
||||
// TomcatInfoModel item = tomcatEditService.getItem(id);
|
||||
// if (item == null) {
|
||||
// return JsonMessage.getString(300, "没有对应数据");
|
||||
// }
|
||||
// JSONArray jsonArray = LayuiTreeUtil.getTreeData(FileUtil.file(item.pathAndCheck(), "logs").getAbsolutePath());
|
||||
// return JsonMessage.getString(200, "", jsonArray);
|
||||
// }
|
||||
//}
|
||||
|
@ -1,42 +1,42 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.controller.tomcat;
|
||||
|
||||
/**
|
||||
* tomcat操作
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/7/22
|
||||
**/
|
||||
public enum TomcatOp {
|
||||
/**
|
||||
* 启动
|
||||
*/
|
||||
start,
|
||||
stop,
|
||||
reload,
|
||||
/**
|
||||
* 删除发布
|
||||
*/
|
||||
undeploy
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.controller.tomcat;
|
||||
//
|
||||
///**
|
||||
// * tomcat操作
|
||||
// *
|
||||
// * @author bwcx_jzy
|
||||
// * @since 2019/7/22
|
||||
// **/
|
||||
//public enum TomcatOp {
|
||||
// /**
|
||||
// * 启动
|
||||
// */
|
||||
// start,
|
||||
// stop,
|
||||
// reload,
|
||||
// /**
|
||||
// * 删除发布
|
||||
// */
|
||||
// undeploy
|
||||
//}
|
||||
|
@ -1,60 +1,60 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.model.data;
|
||||
|
||||
import io.jpom.model.BaseModel;
|
||||
|
||||
/**
|
||||
* jdk 信息
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/10/29
|
||||
*/
|
||||
public class JdkInfoModel extends BaseModel {
|
||||
|
||||
/**
|
||||
* jdk 路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* jdk 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.model.data;
|
||||
//
|
||||
//import io.jpom.model.BaseModel;
|
||||
//
|
||||
///**
|
||||
// * jdk 信息
|
||||
// *
|
||||
// * @author bwcx_jzy
|
||||
// * @since 2019/10/29
|
||||
// */
|
||||
//public class JdkInfoModel extends BaseModel {
|
||||
//
|
||||
// /**
|
||||
// * jdk 路径
|
||||
// */
|
||||
// private String path;
|
||||
//
|
||||
// /**
|
||||
// * jdk 版本
|
||||
// */
|
||||
// private String version;
|
||||
//
|
||||
// public String getPath() {
|
||||
// return path;
|
||||
// }
|
||||
//
|
||||
// public void setPath(String path) {
|
||||
// this.path = path;
|
||||
// }
|
||||
//
|
||||
// public String getVersion() {
|
||||
// return version;
|
||||
// }
|
||||
//
|
||||
// public void setVersion(String version) {
|
||||
// this.version = version;
|
||||
// }
|
||||
//}
|
||||
|
@ -82,7 +82,7 @@ public class NodeProjectInfoModel extends BaseWorkspaceModel {
|
||||
private String token;
|
||||
|
||||
private String createTime;
|
||||
|
||||
@Deprecated
|
||||
private String jdkId;
|
||||
|
||||
private RunMode runMode;
|
||||
|
@ -1,200 +1,200 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.model.data;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import io.jpom.model.BaseModel;
|
||||
import io.jpom.system.JpomRuntimeException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* tomcat 对象实体
|
||||
*
|
||||
* @author lf
|
||||
*/
|
||||
public class TomcatInfoModel extends BaseModel {
|
||||
|
||||
private String path;
|
||||
private int port;
|
||||
private int status;
|
||||
private String appBase;
|
||||
private String creator;
|
||||
private String createTime;
|
||||
private String modifyUser;
|
||||
private String modifyTime;
|
||||
|
||||
public String getPath() {
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
return FileUtil.normalize(path + StrUtil.SLASH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测路径是否正确
|
||||
*
|
||||
* @return path
|
||||
*/
|
||||
public String pathAndCheck() {
|
||||
String path = getPath();
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
if (isTomcatRoot(path)) {
|
||||
return path;
|
||||
}
|
||||
throw new RuntimeException(String.format("没有在路径:%s 下检测到Tomcat", path));
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getAppBase() {
|
||||
if (StrUtil.isEmpty(appBase)) {
|
||||
return FileUtil.normalize(path + "/webapps/");
|
||||
}
|
||||
return FileUtil.normalize(appBase + StrUtil.SLASH);
|
||||
}
|
||||
|
||||
public void setAppBase(String appBase) {
|
||||
this.appBase = appBase;
|
||||
}
|
||||
|
||||
public String getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(String creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getModifyUser() {
|
||||
return modifyUser;
|
||||
}
|
||||
|
||||
public void setModifyUser(String modifyUser) {
|
||||
this.modifyUser = modifyUser;
|
||||
}
|
||||
|
||||
public String getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(String modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否是Tomcat的根路径
|
||||
*
|
||||
* @return 返回是否是Tomcat根路径
|
||||
*/
|
||||
private static boolean isTomcatRoot(String path) {
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
return false;
|
||||
}
|
||||
if (file.isFile()) {
|
||||
return false;
|
||||
}
|
||||
File[] files = file.listFiles();
|
||||
if (files == null) {
|
||||
return false;
|
||||
}
|
||||
// 判断该目录下是否
|
||||
for (File child : files) {
|
||||
if ("bin".equals(child.getName()) && child.isDirectory()) {
|
||||
File[] binFiles = child.listFiles();
|
||||
if (binFiles == null) {
|
||||
return false;
|
||||
}
|
||||
for (File binChild : binFiles) {
|
||||
if ("bootstrap.jar".equals(binChild.getName()) && binChild.isFile()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
public void initTomcat() {
|
||||
String tomcatPath = pathAndCheck();
|
||||
String appBase = getAppBase();
|
||||
if (StrUtil.isEmpty(appBase) || StrUtil.SLASH.equals(appBase)) {
|
||||
File webapps = FileUtil.file(tomcatPath, "webapps");
|
||||
setAppBase(webapps.getAbsolutePath());
|
||||
} else {
|
||||
String path = FileUtil.normalize(appBase);
|
||||
if (FileUtil.isAbsolutePath(path)) {
|
||||
// appBase如:/project/、D:/project/
|
||||
setAppBase(path);
|
||||
} else {
|
||||
// appBase填写的是对相路径如:project/dir
|
||||
File webapps = FileUtil.file(tomcatPath, path);
|
||||
setAppBase(webapps.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
InputStream inputStream = ResourceUtil.getStream("classpath:/bin/jpomAgent.zip");
|
||||
if (inputStream == null) {
|
||||
throw new JpomRuntimeException("jpomAgent.zip不存在");
|
||||
}
|
||||
// 解压代理工具到tomcat的appBase目录下
|
||||
ZipUtil.unzip(inputStream, new File(getAppBase()), CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.model.data;
|
||||
//
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.core.io.resource.ResourceUtil;
|
||||
//import cn.hutool.core.util.CharsetUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.core.util.ZipUtil;
|
||||
//import io.jpom.model.BaseModel;
|
||||
//import io.jpom.system.JpomRuntimeException;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.InputStream;
|
||||
//
|
||||
///**
|
||||
// * tomcat 对象实体
|
||||
// *
|
||||
// * @author lf
|
||||
// */
|
||||
//public class TomcatInfoModel extends BaseModel {
|
||||
//
|
||||
// private String path;
|
||||
// private int port;
|
||||
// private int status;
|
||||
// private String appBase;
|
||||
// private String creator;
|
||||
// private String createTime;
|
||||
// private String modifyUser;
|
||||
// private String modifyTime;
|
||||
//
|
||||
// public String getPath() {
|
||||
// if (path == null) {
|
||||
// return null;
|
||||
// }
|
||||
// return FileUtil.normalize(path + StrUtil.SLASH);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 检测路径是否正确
|
||||
// *
|
||||
// * @return path
|
||||
// */
|
||||
// public String pathAndCheck() {
|
||||
// String path = getPath();
|
||||
// if (path == null) {
|
||||
// return null;
|
||||
// }
|
||||
// if (isTomcatRoot(path)) {
|
||||
// return path;
|
||||
// }
|
||||
// throw new RuntimeException(String.format("没有在路径:%s 下检测到Tomcat", path));
|
||||
// }
|
||||
//
|
||||
// public void setPath(String path) {
|
||||
// this.path = path;
|
||||
// }
|
||||
//
|
||||
// public int getPort() {
|
||||
// return port;
|
||||
// }
|
||||
//
|
||||
// public void setPort(int port) {
|
||||
// this.port = port;
|
||||
// }
|
||||
//
|
||||
// public int getStatus() {
|
||||
// return status;
|
||||
// }
|
||||
//
|
||||
// public void setStatus(int status) {
|
||||
// this.status = status;
|
||||
// }
|
||||
//
|
||||
// public String getAppBase() {
|
||||
// if (StrUtil.isEmpty(appBase)) {
|
||||
// return FileUtil.normalize(path + "/webapps/");
|
||||
// }
|
||||
// return FileUtil.normalize(appBase + StrUtil.SLASH);
|
||||
// }
|
||||
//
|
||||
// public void setAppBase(String appBase) {
|
||||
// this.appBase = appBase;
|
||||
// }
|
||||
//
|
||||
// public String getCreator() {
|
||||
// return creator;
|
||||
// }
|
||||
//
|
||||
// public void setCreator(String creator) {
|
||||
// this.creator = creator;
|
||||
// }
|
||||
//
|
||||
// public String getCreateTime() {
|
||||
// return createTime;
|
||||
// }
|
||||
//
|
||||
// public void setCreateTime(String createTime) {
|
||||
// this.createTime = createTime;
|
||||
// }
|
||||
//
|
||||
// public String getModifyUser() {
|
||||
// return modifyUser;
|
||||
// }
|
||||
//
|
||||
// public void setModifyUser(String modifyUser) {
|
||||
// this.modifyUser = modifyUser;
|
||||
// }
|
||||
//
|
||||
// public String getModifyTime() {
|
||||
// return modifyTime;
|
||||
// }
|
||||
//
|
||||
// public void setModifyTime(String modifyTime) {
|
||||
// this.modifyTime = modifyTime;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 判断是否是Tomcat的根路径
|
||||
// *
|
||||
// * @return 返回是否是Tomcat根路径
|
||||
// */
|
||||
// private static boolean isTomcatRoot(String path) {
|
||||
// File file = new File(path);
|
||||
// if (!file.exists()) {
|
||||
// return false;
|
||||
// }
|
||||
// if (file.isFile()) {
|
||||
// return false;
|
||||
// }
|
||||
// File[] files = file.listFiles();
|
||||
// if (files == null) {
|
||||
// return false;
|
||||
// }
|
||||
// // 判断该目录下是否
|
||||
// for (File child : files) {
|
||||
// if ("bin".equals(child.getName()) && child.isDirectory()) {
|
||||
// File[] binFiles = child.listFiles();
|
||||
// if (binFiles == null) {
|
||||
// return false;
|
||||
// }
|
||||
// for (File binChild : binFiles) {
|
||||
// if ("bootstrap.jar".equals(binChild.getName()) && binChild.isFile()) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 初始化
|
||||
// */
|
||||
// public void initTomcat() {
|
||||
// String tomcatPath = pathAndCheck();
|
||||
// String appBase = getAppBase();
|
||||
// if (StrUtil.isEmpty(appBase) || StrUtil.SLASH.equals(appBase)) {
|
||||
// File webapps = FileUtil.file(tomcatPath, "webapps");
|
||||
// setAppBase(webapps.getAbsolutePath());
|
||||
// } else {
|
||||
// String path = FileUtil.normalize(appBase);
|
||||
// if (FileUtil.isAbsolutePath(path)) {
|
||||
// // appBase如:/project/、D:/project/
|
||||
// setAppBase(path);
|
||||
// } else {
|
||||
// // appBase填写的是对相路径如:project/dir
|
||||
// File webapps = FileUtil.file(tomcatPath, path);
|
||||
// setAppBase(webapps.getAbsolutePath());
|
||||
// }
|
||||
// }
|
||||
// InputStream inputStream = ResourceUtil.getStream("classpath:/bin/jpomAgent.zip");
|
||||
// if (inputStream == null) {
|
||||
// throw new JpomRuntimeException("jpomAgent.zip不存在");
|
||||
// }
|
||||
// // 解压代理工具到tomcat的appBase目录下
|
||||
// ZipUtil.unzip(inputStream, new File(getAppBase()), CharsetUtil.CHARSET_UTF_8);
|
||||
// }
|
||||
//}
|
||||
|
@ -32,9 +32,9 @@ import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.data.NodeScriptModel;
|
||||
import io.jpom.model.system.WorkspaceEnvVarModel;
|
||||
import io.jpom.service.system.AgentWorkspaceEnvVarService;
|
||||
@ -50,8 +50,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 脚本执行
|
||||
|
@ -1,68 +1,68 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.service.manage;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.system.JavaInfo;
|
||||
import cn.hutool.system.JavaRuntimeInfo;
|
||||
import io.jpom.model.data.JdkInfoModel;
|
||||
import io.jpom.service.BaseOperService;
|
||||
import io.jpom.system.AgentConfigBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* jdk 管理
|
||||
*
|
||||
* @author Arno
|
||||
* @since 2019/11/20
|
||||
*/
|
||||
@Service
|
||||
public class JdkInfoService extends BaseOperService<JdkInfoModel> {
|
||||
|
||||
public JdkInfoService() {
|
||||
super(AgentConfigBean.JDK_CONF);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用中的jdk
|
||||
*
|
||||
* @return JdkInfoModel
|
||||
*/
|
||||
private JdkInfoModel getDefaultJdk() {
|
||||
JavaRuntimeInfo info = new JavaRuntimeInfo();
|
||||
String homeDir = info.getHomeDir();
|
||||
String version = new JavaInfo().getVersion();
|
||||
if (StrUtil.isEmpty(homeDir) || StrUtil.isEmpty(version)) {
|
||||
return null;
|
||||
}
|
||||
String path = FileUtil.normalize(homeDir.replace("jre", ""));
|
||||
JdkInfoModel jdkInfoModel = new JdkInfoModel();
|
||||
jdkInfoModel.setId(IdUtil.fastUUID());
|
||||
jdkInfoModel.setVersion(version);
|
||||
jdkInfoModel.setPath(path);
|
||||
return jdkInfoModel;
|
||||
}
|
||||
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.service.manage;
|
||||
//
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.core.util.IdUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.system.JavaInfo;
|
||||
//import cn.hutool.system.JavaRuntimeInfo;
|
||||
//import io.jpom.model.data.JdkInfoModel;
|
||||
//import io.jpom.service.BaseOperService;
|
||||
//import io.jpom.system.AgentConfigBean;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
///**
|
||||
// * jdk 管理
|
||||
// *
|
||||
// * @author Arno
|
||||
// * @since 2019/11/20
|
||||
// */
|
||||
//@Service
|
||||
//public class JdkInfoService extends BaseOperService<JdkInfoModel> {
|
||||
//
|
||||
// public JdkInfoService() {
|
||||
// super(AgentConfigBean.JDK_CONF);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 使用中的jdk
|
||||
// *
|
||||
// * @return JdkInfoModel
|
||||
// */
|
||||
// private JdkInfoModel getDefaultJdk() {
|
||||
// JavaRuntimeInfo info = new JavaRuntimeInfo();
|
||||
// String homeDir = info.getHomeDir();
|
||||
// String version = new JavaInfo().getVersion();
|
||||
// if (StrUtil.isEmpty(homeDir) || StrUtil.isEmpty(version)) {
|
||||
// return null;
|
||||
// }
|
||||
// String path = FileUtil.normalize(homeDir.replace("jre", ""));
|
||||
// JdkInfoModel jdkInfoModel = new JdkInfoModel();
|
||||
// jdkInfoModel.setId(IdUtil.fastUUID());
|
||||
// jdkInfoModel.setVersion(version);
|
||||
// jdkInfoModel.setPath(path);
|
||||
// return jdkInfoModel;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
@ -1,92 +1,92 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.service.manage;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.model.data.TomcatInfoModel;
|
||||
import io.jpom.service.BaseOperService;
|
||||
import io.jpom.system.AgentConfigBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author lf
|
||||
*/
|
||||
@Service
|
||||
public class TomcatEditService extends BaseOperService<TomcatInfoModel> {
|
||||
|
||||
|
||||
public TomcatEditService() {
|
||||
super(AgentConfigBean.TOMCAT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据tomcat名称查询tomcat信息
|
||||
*
|
||||
* @param name tomcat的名称
|
||||
* @return tomcat信息
|
||||
*/
|
||||
public TomcatInfoModel getItemByName(String name) {
|
||||
JSONObject allTomcat = getJSONObject(AgentConfigBean.TOMCAT);
|
||||
|
||||
if (allTomcat == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONObject tomcat = null;
|
||||
for (String key : allTomcat.keySet()) {
|
||||
JSONObject object = allTomcat.getJSONObject(key);
|
||||
if (name.equals(object.getString("name"))) {
|
||||
tomcat = object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return JSONObject.toJavaObject(tomcat, TomcatInfoModel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加Tomcat
|
||||
*
|
||||
* @param tomcatInfoModel tomcat信息
|
||||
*/
|
||||
@Override
|
||||
public void addItem(TomcatInfoModel tomcatInfoModel) {
|
||||
tomcatInfoModel.setCreateTime(DateUtil.now());
|
||||
super.addItem(tomcatInfoModel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改tomcat信息
|
||||
*
|
||||
* @param tomcatInfoModel tomcat信息
|
||||
*/
|
||||
@Override
|
||||
public void updateItem(TomcatInfoModel tomcatInfoModel) {
|
||||
tomcatInfoModel.setModifyTime(DateUtil.now());
|
||||
super.updateItem(tomcatInfoModel);
|
||||
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.service.manage;
|
||||
//
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import io.jpom.model.data.TomcatInfoModel;
|
||||
//import io.jpom.service.BaseOperService;
|
||||
//import io.jpom.system.AgentConfigBean;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
///**
|
||||
// * @author lf
|
||||
// */
|
||||
//@Service
|
||||
//public class TomcatEditService extends BaseOperService<TomcatInfoModel> {
|
||||
//
|
||||
//
|
||||
// public TomcatEditService() {
|
||||
// super(AgentConfigBean.TOMCAT);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 根据tomcat名称查询tomcat信息
|
||||
// *
|
||||
// * @param name tomcat的名称
|
||||
// * @return tomcat信息
|
||||
// */
|
||||
// public TomcatInfoModel getItemByName(String name) {
|
||||
// JSONObject allTomcat = getJSONObject(AgentConfigBean.TOMCAT);
|
||||
//
|
||||
// if (allTomcat == null) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// JSONObject tomcat = null;
|
||||
// for (String key : allTomcat.keySet()) {
|
||||
// JSONObject object = allTomcat.getJSONObject(key);
|
||||
// if (name.equals(object.getString("name"))) {
|
||||
// tomcat = object;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return JSONObject.toJavaObject(tomcat, TomcatInfoModel.class);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 添加Tomcat
|
||||
// *
|
||||
// * @param tomcatInfoModel tomcat信息
|
||||
// */
|
||||
// @Override
|
||||
// public void addItem(TomcatInfoModel tomcatInfoModel) {
|
||||
// tomcatInfoModel.setCreateTime(DateUtil.now());
|
||||
// super.addItem(tomcatInfoModel);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 修改tomcat信息
|
||||
// *
|
||||
// * @param tomcatInfoModel tomcat信息
|
||||
// */
|
||||
// @Override
|
||||
// public void updateItem(TomcatInfoModel tomcatInfoModel) {
|
||||
// tomcatInfoModel.setModifyTime(DateUtil.now());
|
||||
// super.updateItem(tomcatInfoModel);
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
@ -1,156 +1,156 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.service.manage;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.controller.tomcat.TomcatOp;
|
||||
import io.jpom.model.data.TomcatInfoModel;
|
||||
import io.jpom.system.JpomRuntimeException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/7/21
|
||||
*/
|
||||
@Service
|
||||
public class TomcatManageService {
|
||||
|
||||
@Resource
|
||||
private TomcatEditService tomcatEditService;
|
||||
|
||||
/**
|
||||
* 查询tomcat状态
|
||||
*
|
||||
* @param id tomcat的id
|
||||
* @return tomcat状态0表示未运行,1表示运行中
|
||||
*/
|
||||
public int getTomcatStatus(String id) {
|
||||
int result = 0;
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
String url = String.format("http://127.0.0.1:%d/", tomcatInfoModel.getPort());
|
||||
HttpRequest httpRequest = new HttpRequest(url);
|
||||
// 设置超时时间为3秒
|
||||
httpRequest.setConnectionTimeout(3000);
|
||||
try (HttpResponse httpResponse = httpRequest.execute()) {
|
||||
|
||||
result = 1;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询tomcat的项目列表
|
||||
*
|
||||
* @param id tomcat的id
|
||||
* @return tomcat的项目列表
|
||||
*/
|
||||
public JSONArray getTomcatProjectList(String id) {
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
String body = tomcatCmd(tomcatInfoModel, "text/list");
|
||||
|
||||
String[] result = body.replace(StrUtil.CRLF, "$")
|
||||
.replace("\n", "$")
|
||||
.split("\\$");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
|
||||
for (int i = 1; i < result.length; i++) {
|
||||
String str = result[i];
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String[] strs = str.split(StrUtil.COLON);
|
||||
if (strs[0].endsWith("jpomAgent")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
jsonObject.put("path", StrUtil.SLASH.equals(strs[0]) ? "/ROOT" : strs[0]);
|
||||
jsonObject.put("status", strs[1]);
|
||||
jsonObject.put("session", strs[2]);
|
||||
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 访问tomcat Url
|
||||
*
|
||||
* @param tomcatInfoModel tomcat信息
|
||||
* @param cmd 命令
|
||||
* @return 访问结果
|
||||
*/
|
||||
private String tomcatCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
|
||||
String url = String.format("http://127.0.0.1:%d/jpomAgent/%s", tomcatInfoModel.getPort(), cmd);
|
||||
HttpRequest httpRequest = HttpUtil.createGet(url);
|
||||
// new HttpRequest(url);
|
||||
// 设置超时时间为3秒
|
||||
httpRequest.timeout(3000);
|
||||
String body = "";
|
||||
|
||||
try (HttpResponse httpResponse = httpRequest.execute()) {
|
||||
if (httpResponse.isOk()) {
|
||||
body = httpResponse.body();
|
||||
}
|
||||
if (httpResponse.getStatus() == HttpStatus.HTTP_NOT_FOUND) {
|
||||
// 没有插件
|
||||
tomcatInfoModel.initTomcat();
|
||||
throw new JpomRuntimeException("tomcat 未初始化,已经重新初始化请稍后再试");
|
||||
}
|
||||
} catch (JpomRuntimeException jpom) {
|
||||
throw jpom;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* tomcat项目管理
|
||||
*
|
||||
* @param id tomcat id
|
||||
* @param path 项目路径
|
||||
* @param tomcatOp 执行的操作 start=启动项目 stop=停止项目 relaod=重启项目
|
||||
* @return 操作结果
|
||||
*/
|
||||
public JsonMessage tomcatProjectManage(String id, String path, TomcatOp tomcatOp) {
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
String result = tomcatCmd(tomcatInfoModel, String.format("text/%s?path=%s", tomcatOp.name(), path));
|
||||
|
||||
if (result.startsWith("OK")) {
|
||||
return new JsonMessage(200, "操作成功");
|
||||
} else {
|
||||
return new JsonMessage(500, "操作失败:" + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.service.manage;
|
||||
//
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.http.HttpRequest;
|
||||
//import cn.hutool.http.HttpResponse;
|
||||
//import cn.hutool.http.HttpStatus;
|
||||
//import cn.hutool.http.HttpUtil;
|
||||
//import io.jpom.common.JsonMessage;
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import io.jpom.controller.tomcat.TomcatOp;
|
||||
//import io.jpom.model.data.TomcatInfoModel;
|
||||
//import io.jpom.system.JpomRuntimeException;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//
|
||||
///**
|
||||
// * @author bwcx_jzy
|
||||
// * @since 2019/7/21
|
||||
// */
|
||||
//@Service
|
||||
//public class TomcatManageService {
|
||||
//
|
||||
// @Resource
|
||||
// private TomcatEditService tomcatEditService;
|
||||
//
|
||||
// /**
|
||||
// * 查询tomcat状态
|
||||
// *
|
||||
// * @param id tomcat的id
|
||||
// * @return tomcat状态0表示未运行,1表示运行中
|
||||
// */
|
||||
// public int getTomcatStatus(String id) {
|
||||
// int result = 0;
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
// String url = String.format("http://127.0.0.1:%d/", tomcatInfoModel.getPort());
|
||||
// HttpRequest httpRequest = new HttpRequest(url);
|
||||
// // 设置超时时间为3秒
|
||||
// httpRequest.setConnectionTimeout(3000);
|
||||
// try (HttpResponse httpResponse = httpRequest.execute()) {
|
||||
//
|
||||
// result = 1;
|
||||
// } catch (Exception ignored) {
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询tomcat的项目列表
|
||||
// *
|
||||
// * @param id tomcat的id
|
||||
// * @return tomcat的项目列表
|
||||
// */
|
||||
// public JSONArray getTomcatProjectList(String id) {
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
// String body = tomcatCmd(tomcatInfoModel, "text/list");
|
||||
//
|
||||
// String[] result = body.replace(StrUtil.CRLF, "$")
|
||||
// .replace("\n", "$")
|
||||
// .split("\\$");
|
||||
//
|
||||
// JSONArray jsonArray = new JSONArray();
|
||||
//
|
||||
// for (int i = 1; i < result.length; i++) {
|
||||
// String str = result[i];
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// String[] strs = str.split(StrUtil.COLON);
|
||||
// if (strs[0].endsWith("jpomAgent")) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// jsonObject.put("path", StrUtil.SLASH.equals(strs[0]) ? "/ROOT" : strs[0]);
|
||||
// jsonObject.put("status", strs[1]);
|
||||
// jsonObject.put("session", strs[2]);
|
||||
//
|
||||
// jsonArray.add(jsonObject);
|
||||
// }
|
||||
//
|
||||
// return jsonArray;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 访问tomcat Url
|
||||
// *
|
||||
// * @param tomcatInfoModel tomcat信息
|
||||
// * @param cmd 命令
|
||||
// * @return 访问结果
|
||||
// */
|
||||
// private String tomcatCmd(TomcatInfoModel tomcatInfoModel, String cmd) {
|
||||
// String url = String.format("http://127.0.0.1:%d/jpomAgent/%s", tomcatInfoModel.getPort(), cmd);
|
||||
// HttpRequest httpRequest = HttpUtil.createGet(url);
|
||||
// // new HttpRequest(url);
|
||||
// // 设置超时时间为3秒
|
||||
// httpRequest.timeout(3000);
|
||||
// String body = "";
|
||||
//
|
||||
// try (HttpResponse httpResponse = httpRequest.execute()) {
|
||||
// if (httpResponse.isOk()) {
|
||||
// body = httpResponse.body();
|
||||
// }
|
||||
// if (httpResponse.getStatus() == HttpStatus.HTTP_NOT_FOUND) {
|
||||
// // 没有插件
|
||||
// tomcatInfoModel.initTomcat();
|
||||
// throw new JpomRuntimeException("tomcat 未初始化,已经重新初始化请稍后再试");
|
||||
// }
|
||||
// } catch (JpomRuntimeException jpom) {
|
||||
// throw jpom;
|
||||
// } catch (Exception ignored) {
|
||||
// }
|
||||
//
|
||||
// return body;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * tomcat项目管理
|
||||
// *
|
||||
// * @param id tomcat id
|
||||
// * @param path 项目路径
|
||||
// * @param tomcatOp 执行的操作 start=启动项目 stop=停止项目 relaod=重启项目
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// public JsonMessage tomcatProjectManage(String id, String path, TomcatOp tomcatOp) {
|
||||
// TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(id);
|
||||
// String result = tomcatCmd(tomcatInfoModel, String.format("text/%s?path=%s", tomcatOp.name(), path));
|
||||
//
|
||||
// if (result.startsWith("OK")) {
|
||||
// return new JsonMessage(200, "操作成功");
|
||||
// } else {
|
||||
// return new JsonMessage(500, "操作失败:" + result);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -27,10 +27,10 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.commander.CommandOpResult;
|
||||
import io.jpom.model.data.NodeProjectInfoModel;
|
||||
import io.jpom.service.manage.ConsoleService;
|
||||
|
@ -23,9 +23,9 @@
|
||||
package io.jpom.socket;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.data.NodeScriptModel;
|
||||
import io.jpom.script.ScriptProcessBuilder;
|
||||
import io.jpom.service.script.NodeScriptServer;
|
||||
|
@ -24,13 +24,10 @@ package io.jpom.socket;
|
||||
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.model.data.TomcatInfoModel;
|
||||
import io.jpom.service.manage.TomcatEditService;
|
||||
import io.jpom.system.WebAopLog;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.system.LogbackConfig;
|
||||
import io.jpom.util.SocketSessionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -53,112 +50,81 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Slf4j
|
||||
public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle {
|
||||
|
||||
private TomcatEditService tomcatEditService;
|
||||
|
||||
private static final Map<String, File> CACHE_FILE = new ConcurrentHashMap<>();
|
||||
private static final Map<String, File> CACHE_FILE = new ConcurrentHashMap<>();
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session) {
|
||||
try {
|
||||
if (super.checkAuthorize(session)) {
|
||||
return;
|
||||
}
|
||||
String tomcatId = super.getParameters(session, "tomcatId");
|
||||
if (tomcatEditService == null) {
|
||||
tomcatEditService = SpringUtil.getBean(TomcatEditService.class);
|
||||
}
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(tomcatId);
|
||||
if (tomcatInfoModel == null && !JpomApplication.SYSTEM_ID.equalsIgnoreCase(tomcatId)) {
|
||||
SocketSessionUtil.send(session, "获取tomcat信息错误");
|
||||
session.close();
|
||||
return;
|
||||
}
|
||||
SocketSessionUtil.send(session, "连接成功:" + (tomcatInfoModel == null ? "" : tomcatInfoModel.getName()));
|
||||
} catch (Exception e) {
|
||||
log.error("socket 错误", e);
|
||||
try {
|
||||
SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!"));
|
||||
session.close();
|
||||
} catch (IOException e1) {
|
||||
log.error(e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@OnOpen
|
||||
public void onOpen(Session session) {
|
||||
try {
|
||||
if (super.checkAuthorize(session)) {
|
||||
return;
|
||||
}
|
||||
String tomcatId = super.getParameters(session, "tomcatId");
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session) throws Exception {
|
||||
JSONObject json = JSONObject.parseObject(message);
|
||||
String op = json.getString("op");
|
||||
ConsoleCommandOp consoleCommandOp = ConsoleCommandOp.valueOf(op);
|
||||
if (consoleCommandOp == ConsoleCommandOp.heart) {
|
||||
return;
|
||||
}
|
||||
String tomcatId = json.getString("tomcatId");
|
||||
if (JpomApplication.SYSTEM_ID.equalsIgnoreCase(tomcatId)) {
|
||||
runMsg(session, json);
|
||||
} else {
|
||||
TomcatInfoModel tomcatInfoModel = tomcatEditService.getItem(tomcatId);
|
||||
if (tomcatInfoModel == null) {
|
||||
SocketSessionUtil.send(session, "没有对应tomcat");
|
||||
session.close();
|
||||
return;
|
||||
}
|
||||
runMsg(session, tomcatInfoModel, json);
|
||||
}
|
||||
}
|
||||
if (!JpomApplication.SYSTEM_ID.equalsIgnoreCase(tomcatId)) {
|
||||
SocketSessionUtil.send(session, "获取tomcat信息错误");
|
||||
session.close();
|
||||
return;
|
||||
}
|
||||
SocketSessionUtil.send(session, "连接成功:");
|
||||
} catch (Exception e) {
|
||||
log.error("socket 错误", e);
|
||||
try {
|
||||
SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!"));
|
||||
session.close();
|
||||
} catch (IOException e1) {
|
||||
log.error(e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void runMsg(Session session, JSONObject reqJson) throws Exception {
|
||||
try {
|
||||
String fileName = reqJson.getString("fileName");
|
||||
WebAopLog webAopLog = SpringUtil.getBean(WebAopLog.class);
|
||||
// 进入管理页面后需要实时加载日志
|
||||
File file = FileUtil.file(webAopLog.getPropertyValue(), fileName);
|
||||
File file1 = CACHE_FILE.get(session.getId());
|
||||
if (file1 != null && !file1.equals(file)) {
|
||||
// 离线上一个日志
|
||||
AgentFileTailWatcher.offlineFile(file, session);
|
||||
}
|
||||
try {
|
||||
AgentFileTailWatcher.addWatcher(file, session);
|
||||
CACHE_FILE.put(session.getId(), file);
|
||||
} catch (IOException io) {
|
||||
log.error("监听日志变化", io);
|
||||
SocketSessionUtil.send(session, io.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("执行命令失败", e);
|
||||
SocketSessionUtil.send(session, "执行命令失败,详情如下:");
|
||||
SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e));
|
||||
}
|
||||
}
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session) throws Exception {
|
||||
JSONObject json = JSONObject.parseObject(message);
|
||||
String op = json.getString("op");
|
||||
ConsoleCommandOp consoleCommandOp = ConsoleCommandOp.valueOf(op);
|
||||
if (consoleCommandOp == ConsoleCommandOp.heart) {
|
||||
return;
|
||||
}
|
||||
String tomcatId = json.getString("tomcatId");
|
||||
if (JpomApplication.SYSTEM_ID.equalsIgnoreCase(tomcatId)) {
|
||||
runMsg(session, json);
|
||||
}
|
||||
}
|
||||
|
||||
private void runMsg(Session session, TomcatInfoModel tomcatInfoModel, JSONObject reqJson) throws Exception {
|
||||
try {
|
||||
String fileName = reqJson.getString("fileName");
|
||||
// 进入管理页面后需要实时加载日志
|
||||
File file = FileUtil.file(tomcatInfoModel.getPath(), "logs", fileName);
|
||||
try {
|
||||
AgentFileTailWatcher.addWatcher(file, session);
|
||||
} catch (IOException io) {
|
||||
log.error("监听日志变化", io);
|
||||
SocketSessionUtil.send(session, io.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("执行命令失败", e);
|
||||
SocketSessionUtil.send(session, "执行命令失败,详情如下:");
|
||||
SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e));
|
||||
}
|
||||
}
|
||||
private void runMsg(Session session, JSONObject reqJson) throws Exception {
|
||||
try {
|
||||
String fileName = reqJson.getString("fileName");
|
||||
// 进入管理页面后需要实时加载日志
|
||||
File file = FileUtil.file(LogbackConfig.getPath(), fileName);
|
||||
File file1 = CACHE_FILE.get(session.getId());
|
||||
if (file1 != null && !file1.equals(file)) {
|
||||
// 离线上一个日志
|
||||
AgentFileTailWatcher.offlineFile(file, session);
|
||||
}
|
||||
try {
|
||||
AgentFileTailWatcher.addWatcher(file, session);
|
||||
CACHE_FILE.put(session.getId(), file);
|
||||
} catch (IOException io) {
|
||||
log.error("监听日志变化", io);
|
||||
SocketSessionUtil.send(session, io.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("执行命令失败", e);
|
||||
SocketSessionUtil.send(session, "执行命令失败,详情如下:");
|
||||
SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnClose
|
||||
public void onClose(Session session) {
|
||||
super.onClose(session);
|
||||
}
|
||||
@Override
|
||||
@OnClose
|
||||
public void onClose(Session session) {
|
||||
super.onClose(session);
|
||||
}
|
||||
|
||||
@OnError
|
||||
@Override
|
||||
public void onError(Session session, Throwable thr) {
|
||||
super.onError(session, thr);
|
||||
}
|
||||
@OnError
|
||||
@Override
|
||||
public void onError(Session session, Throwable thr) {
|
||||
super.onError(session, thr);
|
||||
}
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ package io.jpom.socket;
|
||||
|
||||
import cn.hutool.core.lang.Tuple;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.common.Const;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.Type;
|
||||
import io.jpom.model.AgentFileModel;
|
||||
import io.jpom.model.WebSocketMessageModel;
|
||||
|
@ -32,6 +32,7 @@ import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.model.system.AgentAutoUser;
|
||||
import io.jpom.util.JsonFileUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@ -42,97 +43,98 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class AgentAuthorize {
|
||||
|
||||
private static AgentAuthorize agentAuthorize;
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@Value("${" + ConfigBean.AUTHORIZE_USER_KEY + "}")
|
||||
private String agentName;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@Value("${" + ConfigBean.AUTHORIZE_AUTHORIZE_KEY + ":}")
|
||||
private String agentPwd;
|
||||
/**
|
||||
* 授权加密字符串
|
||||
*/
|
||||
private String authorize;
|
||||
private static AgentAuthorize agentAuthorize;
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@Value("${" + ConfigBean.AUTHORIZE_USER_KEY + "}")
|
||||
private String agentName;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@Value("${" + ConfigBean.AUTHORIZE_AUTHORIZE_KEY + ":}")
|
||||
private String agentPwd;
|
||||
/**
|
||||
* 授权加密字符串
|
||||
*/
|
||||
private String authorize;
|
||||
|
||||
/**
|
||||
* 单例
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public static AgentAuthorize getInstance() {
|
||||
if (agentAuthorize == null) {
|
||||
agentAuthorize = SpringUtil.getBean(AgentAuthorize.class);
|
||||
// 登录名不能为空
|
||||
if (StrUtil.isEmpty(agentAuthorize.agentName)) {
|
||||
throw new JpomRuntimeException("The agent login name cannot be empty");
|
||||
}
|
||||
agentAuthorize.checkPwd();
|
||||
// 生成密码授权字符串
|
||||
agentAuthorize.authorize = SecureUtil.sha1(agentAuthorize.agentName + "@" + agentAuthorize.agentPwd);
|
||||
}
|
||||
return agentAuthorize;
|
||||
}
|
||||
/**
|
||||
* 单例
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public static AgentAuthorize getInstance() {
|
||||
if (agentAuthorize == null) {
|
||||
agentAuthorize = SpringUtil.getBean(AgentAuthorize.class);
|
||||
// 登录名不能为空
|
||||
if (StrUtil.isEmpty(agentAuthorize.agentName)) {
|
||||
throw new JpomRuntimeException("The agent login name cannot be empty");
|
||||
}
|
||||
agentAuthorize.checkPwd();
|
||||
// 生成密码授权字符串
|
||||
agentAuthorize.authorize = SecureUtil.sha1(agentAuthorize.agentName + "@" + agentAuthorize.agentPwd);
|
||||
}
|
||||
return agentAuthorize;
|
||||
}
|
||||
|
||||
public String getAgentName() {
|
||||
return agentName;
|
||||
}
|
||||
public String getAgentName() {
|
||||
return agentName;
|
||||
}
|
||||
|
||||
public String getAgentPwd() {
|
||||
return agentPwd;
|
||||
}
|
||||
public String getAgentPwd() {
|
||||
return agentPwd;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断授权是否正确
|
||||
*
|
||||
* @param authorize 授权
|
||||
* @return true 正确
|
||||
*/
|
||||
public boolean checkAuthorize(String authorize) {
|
||||
return StrUtil.equals(authorize, this.authorize);
|
||||
}
|
||||
/**
|
||||
* 判断授权是否正确
|
||||
*
|
||||
* @param authorize 授权
|
||||
* @return true 正确
|
||||
*/
|
||||
public boolean checkAuthorize(String authorize) {
|
||||
return StrUtil.equals(authorize, this.authorize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否配置密码
|
||||
*/
|
||||
private void checkPwd() {
|
||||
String path = ConfigBean.getInstance().getAgentAutoAuthorizeFile(ConfigBean.getInstance().getDataPath());
|
||||
if (StrUtil.isNotEmpty(agentPwd)) {
|
||||
// 有指定密码 清除旧密码信息
|
||||
FileUtil.del(path);
|
||||
Console.log("Authorization information has been customized,account:{}", this.agentName);
|
||||
return;
|
||||
}
|
||||
if (FileUtil.exist(path)) {
|
||||
// 读取旧密码
|
||||
try {
|
||||
String json = FileUtil.readString(path, CharsetUtil.CHARSET_UTF_8);
|
||||
AgentAutoUser autoUser = JSONObject.parseObject(json, AgentAutoUser.class);
|
||||
if (!StrUtil.equals(autoUser.getAgentName(), this.agentName)) {
|
||||
throw new JpomRuntimeException("The existing login name is inconsistent with the configured login name");
|
||||
}
|
||||
String oldAgentPwd = autoUser.getAgentPwd();
|
||||
if (StrUtil.isNotEmpty(oldAgentPwd)) {
|
||||
this.agentPwd = oldAgentPwd;
|
||||
Console.log("Already authorized account:{} password:{} Authorization information storage location:{}", this.agentName, this.agentPwd, FileUtil.getAbsolutePath(path));
|
||||
return;
|
||||
}
|
||||
} catch (JpomRuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
this.agentPwd = RandomUtil.randomString(10);
|
||||
AgentAutoUser autoUser = new AgentAutoUser();
|
||||
autoUser.setAgentName(this.agentName);
|
||||
autoUser.setAgentPwd(this.agentPwd);
|
||||
// 写入文件中
|
||||
JsonFileUtil.saveJson(path, autoUser.toJson());
|
||||
Console.log("Automatically generate authorized account:{} password:{} Authorization information storage location:{}", this.agentName, this.agentPwd, FileUtil.getAbsolutePath(path));
|
||||
}
|
||||
/**
|
||||
* 检查是否配置密码
|
||||
*/
|
||||
private void checkPwd() {
|
||||
String path = ConfigBean.getInstance().getAgentAutoAuthorizeFile(ConfigBean.getInstance().getDataPath());
|
||||
if (StrUtil.isNotEmpty(agentPwd)) {
|
||||
// 有指定密码 清除旧密码信息
|
||||
FileUtil.del(path);
|
||||
Console.log("Authorization information has been customized,account:{}", this.agentName);
|
||||
return;
|
||||
}
|
||||
if (FileUtil.exist(path)) {
|
||||
// 读取旧密码
|
||||
try {
|
||||
String json = FileUtil.readString(path, CharsetUtil.CHARSET_UTF_8);
|
||||
AgentAutoUser autoUser = JSONObject.parseObject(json, AgentAutoUser.class);
|
||||
if (!StrUtil.equals(autoUser.getAgentName(), this.agentName)) {
|
||||
throw new JpomRuntimeException("The existing login name is inconsistent with the configured login name");
|
||||
}
|
||||
String oldAgentPwd = autoUser.getAgentPwd();
|
||||
if (StrUtil.isNotEmpty(oldAgentPwd)) {
|
||||
this.agentPwd = oldAgentPwd;
|
||||
log.info("Already authorized account:{} password:{} Authorization information storage location:{}", this.agentName, this.agentPwd, FileUtil.getAbsolutePath(path));
|
||||
return;
|
||||
}
|
||||
} catch (JpomRuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
this.agentPwd = RandomUtil.randomString(10);
|
||||
AgentAutoUser autoUser = new AgentAutoUser();
|
||||
autoUser.setAgentName(this.agentName);
|
||||
autoUser.setAgentPwd(this.agentPwd);
|
||||
// 写入文件中
|
||||
JsonFileUtil.saveJson(path, autoUser.toJson());
|
||||
Console.log("Automatically generate authorized account:{} password:{} Authorization information storage location:{}", this.agentName, this.agentPwd, FileUtil.getAbsolutePath(path));
|
||||
}
|
||||
}
|
||||
|
@ -38,91 +38,91 @@ import java.io.File;
|
||||
*/
|
||||
@Configuration
|
||||
public class AgentConfigBean {
|
||||
/**
|
||||
* 白名单文件
|
||||
*/
|
||||
public static final String WHITELIST_DIRECTORY = "whitelistDirectory.json";
|
||||
/**
|
||||
* 项目数据文件
|
||||
*/
|
||||
public static final String PROJECT = "project.json";
|
||||
/**
|
||||
* 白名单文件
|
||||
*/
|
||||
public static final String WHITELIST_DIRECTORY = "whitelistDirectory.json";
|
||||
/**
|
||||
* 项目数据文件
|
||||
*/
|
||||
public static final String PROJECT = "project.json";
|
||||
|
||||
public static final String TOMCAT = "tomcat.json";
|
||||
/**
|
||||
* 项目回收文件
|
||||
*/
|
||||
public static final String PROJECT_RECOVER = "project_recover.json";
|
||||
/**
|
||||
* 证书文件
|
||||
*/
|
||||
public static final String CERT = "cert.json";
|
||||
/**
|
||||
* 脚本管理数据文件
|
||||
*/
|
||||
public static final String SCRIPT = "script.json";
|
||||
/**
|
||||
* 脚本管理执行记录数据文件
|
||||
*/
|
||||
public static final String SCRIPT_LOG = "script_log.json";
|
||||
// public static final String TOMCAT = "tomcat.json";
|
||||
/**
|
||||
* 项目回收文件
|
||||
*/
|
||||
public static final String PROJECT_RECOVER = "project_recover.json";
|
||||
/**
|
||||
* 证书文件
|
||||
*/
|
||||
public static final String CERT = "cert.json";
|
||||
/**
|
||||
* 脚本管理数据文件
|
||||
*/
|
||||
public static final String SCRIPT = "script.json";
|
||||
/**
|
||||
* 脚本管理执行记录数据文件
|
||||
*/
|
||||
public static final String SCRIPT_LOG = "script_log.json";
|
||||
|
||||
/**
|
||||
* Server 端的信息
|
||||
*/
|
||||
public static final String SERVER_ID = "SERVER.json";
|
||||
/**
|
||||
* Server 端的信息
|
||||
*/
|
||||
public static final String SERVER_ID = "SERVER.json";
|
||||
|
||||
/**
|
||||
* nginx配置信息
|
||||
*/
|
||||
public static final String NGINX_CONF = "nginx_conf.json";
|
||||
/**
|
||||
* nginx配置信息
|
||||
*/
|
||||
public static final String NGINX_CONF = "nginx_conf.json";
|
||||
|
||||
/**
|
||||
* jdk列表信息
|
||||
*/
|
||||
public static final String JDK_CONF = "jdk_conf.json";
|
||||
/**
|
||||
* jdk列表信息
|
||||
*/
|
||||
// public static final String JDK_CONF = "jdk_conf.json";
|
||||
|
||||
/**
|
||||
* 环境变量列表信息
|
||||
*/
|
||||
public static final String WORKSPACE_ENV_VAR = "workspace_env_var.json";
|
||||
public static final String WORKSPACE_ENV_VAR = "workspace_env_var.json";
|
||||
|
||||
|
||||
private static AgentConfigBean agentConfigBean;
|
||||
private static AgentConfigBean agentConfigBean;
|
||||
|
||||
/**
|
||||
* 单利模式
|
||||
*
|
||||
* @return config
|
||||
*/
|
||||
public static AgentConfigBean getInstance() {
|
||||
if (agentConfigBean == null) {
|
||||
agentConfigBean = SpringUtil.getBean(AgentConfigBean.class);
|
||||
}
|
||||
return agentConfigBean;
|
||||
}
|
||||
/**
|
||||
* 单利模式
|
||||
*
|
||||
* @return config
|
||||
*/
|
||||
public static AgentConfigBean getInstance() {
|
||||
if (agentConfigBean == null) {
|
||||
agentConfigBean = SpringUtil.getBean(AgentConfigBean.class);
|
||||
}
|
||||
return agentConfigBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的临时文件存储路径,如果没有登录则抛出异常
|
||||
*
|
||||
* @return 文件夹
|
||||
*/
|
||||
public String getTempPathName() {
|
||||
File file = getTempPath();
|
||||
return FileUtil.normalize(file.getPath());
|
||||
}
|
||||
/**
|
||||
* 获取当前登录用户的临时文件存储路径,如果没有登录则抛出异常
|
||||
*
|
||||
* @return 文件夹
|
||||
*/
|
||||
public String getTempPathName() {
|
||||
File file = getTempPath();
|
||||
return FileUtil.normalize(file.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的临时文件存储路径,如果没有登录则抛出异常
|
||||
*
|
||||
* @return file
|
||||
*/
|
||||
public File getTempPath() {
|
||||
File file = ConfigBean.getInstance().getTempPath();
|
||||
String userName = BaseAgentController.getNowUserName();
|
||||
if (StrUtil.isEmpty(userName)) {
|
||||
throw new JpomRuntimeException("没有登录");
|
||||
}
|
||||
file = FileUtil.file(file, userName);
|
||||
FileUtil.mkdir(file);
|
||||
return file;
|
||||
}
|
||||
/**
|
||||
* 获取当前登录用户的临时文件存储路径,如果没有登录则抛出异常
|
||||
*
|
||||
* @return file
|
||||
*/
|
||||
public File getTempPath() {
|
||||
File file = ConfigBean.getInstance().getTempPath();
|
||||
String userName = BaseAgentController.getNowUserName();
|
||||
if (StrUtil.isEmpty(userName)) {
|
||||
throw new JpomRuntimeException("没有登录");
|
||||
}
|
||||
file = FileUtil.file(file, userName);
|
||||
FileUtil.mkdir(file);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,11 @@ import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.PreLoadClass;
|
||||
import cn.jiangzeyin.common.PreLoadMethod;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.ServerOpenApi;
|
||||
import io.jpom.system.AgentAuthorize;
|
||||
import io.jpom.system.AgentConfigBean;
|
||||
|
@ -1,5 +0,0 @@
|
||||
project:
|
||||
# 项目文件备份保留个数,大于 0 才会备份
|
||||
fileBackupCount: 5
|
||||
# 限制备份指定文件后缀(支持正则)
|
||||
#fileBackupSuffix: [ '.jar','.html','^.+\\.(?i)(txt)$' ]
|
@ -1,7 +1,82 @@
|
||||
# see extConfigDefault.yml
|
||||
jpom:
|
||||
# jpom 数据存储路径, 如果调试模式运行默认路径为【${user.home}/jpom/】,安装运行默认为jar包文件的父级
|
||||
path:
|
||||
authorize:
|
||||
# agent 端管理账号,必填。
|
||||
agentName: jpomAgent
|
||||
# agent 端管理密码,非必填,如果为空Jpom 会自动生成一串随机字符串当密码
|
||||
agentPwd:
|
||||
agent:
|
||||
# 设置插件端id,配置自动注册服务端需要
|
||||
id:
|
||||
# 当前节点插件端可以访问的url ,如果不设置将使用http://+本地IP+端口
|
||||
url:
|
||||
server:
|
||||
# 设置服务端的url
|
||||
url:
|
||||
# 服务器接口请求token
|
||||
token:
|
||||
whitelistDirectory:
|
||||
# 白名单目录是否验证包含关系
|
||||
checkStartsWith: true
|
||||
log:
|
||||
# 检测控制台日志周期,防止日志文件过大,目前暂只支持linux 不停服备份
|
||||
autoBackConsoleCron: 0 0/10 * * * ?
|
||||
# 控制台日志文件保留大小
|
||||
autoBackSize: 50MB
|
||||
# 是否自动将控制台日志文件备份
|
||||
autoBackToFile: true
|
||||
# 保存天数 配置错误或者没有,默认是7天
|
||||
saveDays: 7
|
||||
# 日志文件的编码格式,如果没有指定就自动识别,自动识别可能出现不准确的情况
|
||||
fileCharset:
|
||||
# 查看日志时初始读取最后多少行(默认10,0不读取)
|
||||
intiReadLine: 10
|
||||
consoleLog:
|
||||
# 是否记录接口请求日志
|
||||
reqXss: true
|
||||
# 是否记录接口响应日志
|
||||
reqResponse: true
|
||||
# 控制台编码格式
|
||||
charset:
|
||||
project:
|
||||
# 停止、启动项目(项目状态检测)等待的时长 单位秒
|
||||
stopWaitTime: 10
|
||||
# 项目文件备份保留个数,大于 0 才会备份
|
||||
fileBackupCount: 0
|
||||
# 限制备份指定文件后缀(支持正则)
|
||||
#fileBackupSuffix: [ '.jar','.html','^.+\\.(?i)(txt)$' ]
|
||||
# 项目状态检测间隔时间 单位毫秒,最小为1毫秒
|
||||
statusDetectionInterval: 500
|
||||
system:
|
||||
# cron 定时器是否开启匹配秒
|
||||
timerMatchSecond: false
|
||||
# 旧包文件保留个数
|
||||
oldJarsCount: 2
|
||||
# Check the url for the new version
|
||||
remoteVersionUrl:
|
||||
#运行端口号
|
||||
|
||||
server:
|
||||
port: 2123
|
||||
spring:
|
||||
application:
|
||||
name: jpomAgent
|
||||
profiles:
|
||||
active: local
|
||||
servlet:
|
||||
session:
|
||||
timeout: 1H
|
||||
cookie:
|
||||
name: JPOMID-AGENT
|
||||
multipart:
|
||||
# 上传文件大小限制 12KB -- parses as 12 kilobytes 5MB -- parses as 5 megabytes 20 -- parses as 20 kilobytes
|
||||
max-request-size: 2GB
|
||||
max-file-size: 1GB
|
||||
banner:
|
||||
msg: classpath:/jpom-logo.txt
|
||||
# 启动完成自动初始化指定包
|
||||
preload:
|
||||
packageName: io.jpom.system.init
|
||||
# 强制去掉空格
|
||||
request:
|
||||
trimAll: true
|
||||
urlDecode: true
|
||||
|
@ -1,25 +0,0 @@
|
||||
#运行端口号
|
||||
server:
|
||||
port: 2123
|
||||
servlet:
|
||||
session:
|
||||
timeout: 1H
|
||||
cookie:
|
||||
name: JPOMID-AGENT
|
||||
spring:
|
||||
application:
|
||||
name: jpomAgent
|
||||
servlet:
|
||||
multipart:
|
||||
# 上传文件大小限制 12KB -- parses as 12 kilobytes 5MB -- parses as 5 megabytes 20 -- parses as 20 kilobytes
|
||||
max-request-size: 2GB
|
||||
max-file-size: 1GB
|
||||
banner:
|
||||
msg: Jpom-Agent Starting
|
||||
# 启动完成自动初始化指定包
|
||||
preload:
|
||||
packageName: io.jpom.system.init
|
||||
# 强制去掉空格
|
||||
request:
|
||||
trimAll: true
|
||||
urlDecode: true
|
Binary file not shown.
@ -55,10 +55,26 @@ system:
|
||||
oldJarsCount: 2
|
||||
# Check the url for the new version
|
||||
remoteVersionUrl:
|
||||
# spring 相关配置
|
||||
#运行端口号
|
||||
spring:
|
||||
port: 2123
|
||||
application:
|
||||
name: jpomAgent
|
||||
servlet:
|
||||
session:
|
||||
timeout: 1H
|
||||
cookie:
|
||||
name: JPOMID-AGENT
|
||||
multipart:
|
||||
# 上传文件大小限制 12KB -- parses as 12 kilobytes 5MB -- parses as 5 megabytes 20 -- parses as 20 kilobytes
|
||||
max-request-size: 2GB
|
||||
max-file-size: 1GB
|
||||
banner:
|
||||
msg: classpath:/jpom-logo.txt
|
||||
# 启动完成自动初始化指定包
|
||||
preload:
|
||||
packageName: io.jpom.system.init
|
||||
# 强制去掉空格
|
||||
request:
|
||||
trimAll: true
|
||||
urlDecode: true
|
68
modules/agent/src/main/resources/config_default/logback.xml
Normal file
68
modules/agent/src/main/resources/config_default/logback.xml
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Code Technology Studio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
-->
|
||||
<configuration scan="true" scanPeriod=" 5 seconds">
|
||||
|
||||
<!--动态定义日志路径,请勿修改将影响查看系统日志功能-->
|
||||
<define name="logPath" class="io.jpom.system.LogbackConfig"/>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{10} [%file:%line] - %msg%n</pattern>
|
||||
<!-- <pattern><![CDATA[%date %level [%thread] %logger{10} [%file:%line]- x:\(%X\) %msg %n]]></pattern>-->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="LOG-ROOT" class="ch.qos.logback.classic.sift.SiftingAppender">
|
||||
<discriminator>
|
||||
<Key>destination</Key>
|
||||
<DefaultValue>agent</DefaultValue>
|
||||
</discriminator>
|
||||
<sift>
|
||||
<appender name="FILE-${destination}" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${logPath}/${destination}.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- rollover daily -->
|
||||
<fileNamePattern>${logPath}/%d{yyyy-MM-dd}/${destination}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<!-- or whenever the file size reaches 100MB -->
|
||||
<maxFileSize>512MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>
|
||||
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{10} [%file:%line] - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
</sift>
|
||||
</appender>
|
||||
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="LOG-ROOT"/>
|
||||
</root>
|
||||
</configuration>
|
69
modules/agent/src/main/resources/logback.xml
Normal file
69
modules/agent/src/main/resources/logback.xml
Normal file
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Code Technology Studio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
-->
|
||||
<configuration scan="true" scanPeriod=" 5 seconds">
|
||||
|
||||
<!--动态定义日志路径,请勿修改将影响查看系统日志功能-->
|
||||
<define name="logPath" class="io.jpom.system.LogbackConfig"/>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{10} [%file:%line] - %msg%n</pattern>
|
||||
<!-- <pattern><![CDATA[%date %level [%thread] %logger{10} [%file:%line]- x:\(%X\) %msg %n]]></pattern>-->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="LOG-ROOT" class="ch.qos.logback.classic.sift.SiftingAppender">
|
||||
<discriminator>
|
||||
<Key>destination</Key>
|
||||
<DefaultValue>agent</DefaultValue>
|
||||
</discriminator>
|
||||
<sift>
|
||||
<appender name="FILE-${destination}" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${logPath}/${destination}.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- rollover daily -->
|
||||
<fileNamePattern>${logPath}/%d{yyyy-MM-dd}/${destination}-%d{yyyy-MM-dd}-%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<!-- or whenever the file size reaches 100MB -->
|
||||
<maxFileSize>512MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>
|
||||
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{10} [%file:%line] - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
</sift>
|
||||
</appender>
|
||||
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="LOG-ROOT"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
@ -1,43 +1,43 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
import io.jpom.util.FileUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/10/30
|
||||
*/
|
||||
public class TestJdkTest {
|
||||
|
||||
@Test
|
||||
public void t() {
|
||||
String path = "C:\\Program Files\\Java\\jdk1.8.0_211";
|
||||
System.out.println(FileUtils.isJdkPath(path));
|
||||
//
|
||||
|
||||
|
||||
String version = FileUtils.getJdkVersion(path);
|
||||
System.out.println(version);
|
||||
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//import io.jpom.util.FileUtils;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
///**
|
||||
// * @author bwcx_jzy
|
||||
// * @since 2019/10/30
|
||||
// */
|
||||
//public class TestJdkTest {
|
||||
//
|
||||
// @Test
|
||||
// public void t() {
|
||||
// String path = "C:\\Program Files\\Java\\jdk1.8.0_211";
|
||||
// System.out.println(FileUtils.isJdkPath(path));
|
||||
// //
|
||||
//
|
||||
//
|
||||
// String version = FileUtils.getJdkVersion(path);
|
||||
// System.out.println(version);
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
@ -22,14 +22,15 @@
|
||||
*/
|
||||
package io.jpom;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.LineHandler;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.jiangzeyin.common.ApplicationBuilder;
|
||||
import cn.jiangzeyin.common.validator.ParameterInterceptor;
|
||||
@ -39,25 +40,22 @@ import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.jpom.common.Const;
|
||||
import io.jpom.common.JpomApplicationEvent;
|
||||
import io.jpom.common.JpomAppType;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.Type;
|
||||
import io.jpom.plugin.PluginFactory;
|
||||
import io.jpom.system.ExtConfigBean;
|
||||
import io.jpom.util.CommandUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -74,37 +72,9 @@ public class JpomApplication extends ApplicationBuilder {
|
||||
*/
|
||||
public static final String SYSTEM_ID = "system";
|
||||
|
||||
protected static String[] args;
|
||||
/**
|
||||
* 应用类型
|
||||
*/
|
||||
private static Type appType;
|
||||
private static Charset charset;
|
||||
|
||||
private static Class<?> appClass;
|
||||
|
||||
/**
|
||||
* 获取程序命令行参数
|
||||
*
|
||||
* @return 数组
|
||||
*/
|
||||
public static String[] getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public JpomApplication(Type appType, Class<?> appClass, String[] args) throws Exception {
|
||||
public JpomApplication(Class<?> appClass) throws Exception {
|
||||
super(appClass);
|
||||
//
|
||||
checkEvent(args);
|
||||
JpomApplication.appType = appType;
|
||||
JpomApplication.appClass = appClass;
|
||||
JpomApplication.args = args;
|
||||
// 检查 type 中的 applicationClass 配置是否正确
|
||||
String applicationClass = appType.getApplicationClass();
|
||||
Assert.state(StrUtil.equals(applicationClass, appClass.getName()), "The currently allowed classes are inconsistent with the configured class names:io.jpom.common.Type#getApplicationClass()");
|
||||
|
||||
addHttpMessageConverter(new StringHttpMessageConverter(CharsetUtil.CHARSET_UTF_8));
|
||||
|
||||
//
|
||||
ObjectMapper build = createJackson();
|
||||
addHttpMessageConverter(new MappingJackson2HttpMessageConverter(build));
|
||||
@ -112,13 +82,6 @@ public class JpomApplication extends ApplicationBuilder {
|
||||
// 参数拦截器
|
||||
addInterceptor(ParameterInterceptor.class);
|
||||
// addInterceptor(PluginFeatureInterceptor.class);
|
||||
//
|
||||
addApplicationEventClient(new JpomApplicationEvent());
|
||||
// 添加初始化监听
|
||||
PluginFactory pluginFactory = new PluginFactory();
|
||||
SpringApplication application = this.application();
|
||||
application.addListeners(pluginFactory);
|
||||
application.addInitializers(pluginFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,9 +109,9 @@ public class JpomApplication extends ApplicationBuilder {
|
||||
return build;
|
||||
}
|
||||
|
||||
private void checkEvent(String[] args) throws Exception {
|
||||
new JpomClose().main(args);
|
||||
}
|
||||
// private void checkEvent(String[] args) throws Exception {
|
||||
// new JpomClose().main(args);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 获取当前系统编码
|
||||
@ -174,22 +137,21 @@ public class JpomApplication extends ApplicationBuilder {
|
||||
* @return Agent 或者 Server
|
||||
*/
|
||||
public static Type getAppType() {
|
||||
if (appType == null) {
|
||||
// 从配置文件中获取
|
||||
Environment environment = JpomApplication.getEnvironment();
|
||||
String property = environment.getProperty(Const.APPLICATION_NAME);
|
||||
property = StrUtil.removeAll(property, "jpom");
|
||||
Assert.hasLength(property, "Please configure the program type:" + Const.APPLICATION_NAME);
|
||||
appType = Type.valueOf(property);
|
||||
}
|
||||
return appType;
|
||||
Map<String, Object> beansWithAnnotation = SpringUtil.getApplicationContext().getBeansWithAnnotation(JpomAppType.class);
|
||||
Class<?> jpomAppClass = Optional.of(beansWithAnnotation)
|
||||
.map(map -> CollUtil.getFirst(map.values()))
|
||||
.map(Object::getClass)
|
||||
.orElseThrow(() -> new RuntimeException("没有找到 Jpom 类型配置"));
|
||||
JpomAppType jpomAppType = jpomAppClass.getAnnotation(JpomAppType.class);
|
||||
return jpomAppType.value();
|
||||
}
|
||||
|
||||
public static Class<?> getAppClass() {
|
||||
if (appClass == null) {
|
||||
return JpomApplication.class;
|
||||
}
|
||||
return appClass;
|
||||
Map<String, Object> beansWithAnnotation = SpringUtil.getApplicationContext().getBeansWithAnnotation(SpringBootApplication.class);
|
||||
return Optional.of(beansWithAnnotation)
|
||||
.map(map -> CollUtil.getFirst(map.values()))
|
||||
.map(Object::getClass)
|
||||
.orElseThrow(() -> new RuntimeException("没有找到运行的主类"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,124 +1,124 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import io.jpom.util.CommandUtil;
|
||||
import io.jpom.util.JvmUtil;
|
||||
import io.jpom.util.StringUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 命令行关闭Jpom
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @since 2019/4/7
|
||||
*/
|
||||
public class JpomClose {
|
||||
private static JpomClose jpomManager;
|
||||
|
||||
public void main(String[] args) throws Exception {
|
||||
String tag = StringUtil.getArgsValue(args, "jpom.applicationTag");
|
||||
if (StrUtil.isEmpty(tag)) {
|
||||
return;
|
||||
}
|
||||
// 事件
|
||||
String event = StringUtil.getArgsValue(args, "event");
|
||||
if ("stop".equalsIgnoreCase(event)) {
|
||||
String status = JpomClose.getInstance().status(tag);
|
||||
if (!status.contains(StrUtil.COLON)) {
|
||||
Console.error("Jpom并没有运行");
|
||||
} else {
|
||||
String msg = JpomClose.getInstance().stop(tag);
|
||||
Console.log(msg);
|
||||
}
|
||||
System.exit(0);
|
||||
} else if ("status".equalsIgnoreCase(event)) {
|
||||
String status = JpomClose.getInstance().status(tag);
|
||||
Console.log(status);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单利模式
|
||||
*
|
||||
* @return JpomClose
|
||||
*/
|
||||
public static JpomClose getInstance() {
|
||||
if (jpomManager != null) {
|
||||
return jpomManager;
|
||||
}
|
||||
if (SystemUtil.getOsInfo().isLinux()) {
|
||||
jpomManager = new Linux();
|
||||
} else {
|
||||
jpomManager = new Windows();
|
||||
}
|
||||
return jpomManager;
|
||||
}
|
||||
|
||||
|
||||
public String stop(String tag) throws IOException {
|
||||
Integer pid = JvmUtil.getPidByTag(tag);
|
||||
return ObjectUtil.toString(pid);
|
||||
}
|
||||
|
||||
public String status(String tag) throws IOException {
|
||||
Integer pid = JvmUtil.getPidByTag(tag);
|
||||
if (pid == null) {
|
||||
return "Jpom并没有运行";
|
||||
}
|
||||
return "Jpom运行中:" + pid;
|
||||
}
|
||||
|
||||
|
||||
private static class Windows extends JpomClose {
|
||||
|
||||
@Override
|
||||
public String stop(String tag) throws IOException {
|
||||
String pid = super.stop(tag);
|
||||
if (pid == null) {
|
||||
return "stop";
|
||||
}
|
||||
String cmd = String.format("taskkill /F /PID %s", pid);
|
||||
return CommandUtil.execSystemCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Linux extends JpomClose {
|
||||
|
||||
@Override
|
||||
public String stop(String tag) throws IOException {
|
||||
String pid = super.stop(tag);
|
||||
if (pid == null) {
|
||||
return "stop";
|
||||
}
|
||||
String cmd = String.format("kill %s", pid);
|
||||
return CommandUtil.execSystemCommand(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom;
|
||||
//
|
||||
//import cn.hutool.core.lang.Console;
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import cn.hutool.system.SystemUtil;
|
||||
//import io.jpom.util.CommandUtil;
|
||||
//import io.jpom.util.JvmUtil;
|
||||
//import io.jpom.util.StringUtil;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
///**
|
||||
// * 命令行关闭Jpom
|
||||
// *
|
||||
// * @author jiangzeyin
|
||||
// * @since 2019/4/7
|
||||
// */
|
||||
//public class JpomClose {
|
||||
// private static JpomClose jpomManager;
|
||||
//
|
||||
// public void main(String[] args) throws Exception {
|
||||
// String tag = StringUtil.getArgsValue(args, "jpom.applicationTag");
|
||||
// if (StrUtil.isEmpty(tag)) {
|
||||
// return;
|
||||
// }
|
||||
// // 事件
|
||||
// String event = StringUtil.getArgsValue(args, "event");
|
||||
// if ("stop".equalsIgnoreCase(event)) {
|
||||
// String status = JpomClose.getInstance().status(tag);
|
||||
// if (!status.contains(StrUtil.COLON)) {
|
||||
// Console.error("Jpom并没有运行");
|
||||
// } else {
|
||||
// String msg = JpomClose.getInstance().stop(tag);
|
||||
// Console.log(msg);
|
||||
// }
|
||||
// System.exit(0);
|
||||
// } else if ("status".equalsIgnoreCase(event)) {
|
||||
// String status = JpomClose.getInstance().status(tag);
|
||||
// Console.log(status);
|
||||
// System.exit(0);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 单利模式
|
||||
// *
|
||||
// * @return JpomClose
|
||||
// */
|
||||
// public static JpomClose getInstance() {
|
||||
// if (jpomManager != null) {
|
||||
// return jpomManager;
|
||||
// }
|
||||
// if (SystemUtil.getOsInfo().isLinux()) {
|
||||
// jpomManager = new Linux();
|
||||
// } else {
|
||||
// jpomManager = new Windows();
|
||||
// }
|
||||
// return jpomManager;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public String stop(String tag) throws IOException {
|
||||
// Integer pid = JvmUtil.getPidByTag(tag);
|
||||
// return ObjectUtil.toString(pid);
|
||||
// }
|
||||
//
|
||||
// public String status(String tag) throws IOException {
|
||||
// Integer pid = JvmUtil.getPidByTag(tag);
|
||||
// if (pid == null) {
|
||||
// return "Jpom并没有运行";
|
||||
// }
|
||||
// return "Jpom运行中:" + pid;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private static class Windows extends JpomClose {
|
||||
//
|
||||
// @Override
|
||||
// public String stop(String tag) throws IOException {
|
||||
// String pid = super.stop(tag);
|
||||
// if (pid == null) {
|
||||
// return "stop";
|
||||
// }
|
||||
// String cmd = String.format("taskkill /F /PID %s", pid);
|
||||
// return CommandUtil.execSystemCommand(cmd);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class Linux extends JpomClose {
|
||||
//
|
||||
// @Override
|
||||
// public String stop(String tag) throws IOException {
|
||||
// String pid = super.stop(tag);
|
||||
// if (pid == null) {
|
||||
// return "stop";
|
||||
// }
|
||||
// String cmd = String.format("kill %s", pid);
|
||||
// return CommandUtil.execSystemCommand(cmd);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@ -23,7 +23,6 @@
|
||||
package io.jpom.common;
|
||||
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.controller.BaseMyErrorController;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
16
modules/common/src/main/java/io/jpom/common/JpomAppType.java
Normal file
16
modules/common/src/main/java/io/jpom/common/JpomAppType.java
Normal file
@ -0,0 +1,16 @@
|
||||
package io.jpom.common;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @since 2022/12/8
|
||||
*/
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface JpomAppType {
|
||||
|
||||
Type value();
|
||||
}
|
@ -23,33 +23,40 @@
|
||||
package io.jpom.common;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import cn.jiangzeyin.common.spring.event.ApplicationEventClient;
|
||||
import cn.jiangzeyin.common.spring.event.ApplicationEventLoad;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.cron.IAsyncLoad;
|
||||
import io.jpom.cron.ICron;
|
||||
import io.jpom.system.ConfigBean;
|
||||
import io.jpom.system.ExtConfigBean;
|
||||
import io.jpom.util.JsonFileUtil;
|
||||
import io.jpom.util.JvmUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileLock;
|
||||
import java.nio.channels.OverlappingFileLockException;
|
||||
import java.nio.file.AccessDeniedException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 启动 、关闭监听
|
||||
@ -58,160 +65,232 @@ import java.util.List;
|
||||
* @since 2019/4/7
|
||||
*/
|
||||
@Slf4j
|
||||
public class JpomApplicationEvent implements ApplicationEventClient {
|
||||
private FileLock lock;
|
||||
private FileOutputStream fileOutputStream;
|
||||
private FileChannel fileChannel;
|
||||
@Configuration
|
||||
public class JpomApplicationEvent implements ApplicationListener<ApplicationEvent> {
|
||||
|
||||
private final ExtConfigBean extConfigBean;
|
||||
|
||||
public JpomApplicationEvent(ExtConfigBean extConfigBean) {
|
||||
this.extConfigBean = extConfigBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
// 启动最后的预加载
|
||||
if (event instanceof ApplicationReadyEvent) {
|
||||
this.clearTemp();
|
||||
this.checkDuplicateRun();
|
||||
//
|
||||
this.checkPath();
|
||||
JpomManifest jpomManifest = JpomManifest.getInstance();
|
||||
ConfigBean instance = ConfigBean.getInstance();
|
||||
// 清理旧进程新文件
|
||||
File dataDir = FileUtil.file(instance.getDataPath());
|
||||
List<File> files = FileUtil.loopFiles(dataDir, 1, pathname -> pathname.getName().startsWith("pid."));
|
||||
files.forEach(FileUtil::del);
|
||||
|
||||
// 写入Jpom 信息 、 写入全局信息
|
||||
File appJpomFile = instance.getApplicationJpomInfo(JpomApplication.getAppType());
|
||||
FileUtil.writeString(jpomManifest.toString(), appJpomFile, CharsetUtil.CHARSET_UTF_8);
|
||||
// 检查更新文件
|
||||
this.checkUpdate();
|
||||
//
|
||||
this.reqXssLog();
|
||||
this.statLoad();
|
||||
this.success();
|
||||
} else if (event instanceof ContextClosedEvent) {
|
||||
//
|
||||
ConfigBean instance = ConfigBean.getInstance();
|
||||
FileUtil.del(instance.getPidFile());
|
||||
//
|
||||
File appJpomFile = instance.getApplicationJpomInfo(JpomApplication.getAppType());
|
||||
FileUtil.del(appJpomFile);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPath() {
|
||||
String path = extConfigBean.getPath();
|
||||
String extConfigPath = null;
|
||||
try {
|
||||
extConfigPath = ExtConfigBean.getResource().getURL().toString();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
File file = FileUtil.file(path);
|
||||
try {
|
||||
FileUtil.mkdir(file);
|
||||
file = FileUtil.createTempFile("jpom", ".temp", file, true);
|
||||
} catch (Exception e) {
|
||||
log.error(StrUtil.format("Jpom Failed to create data directory, directory location:{}," +
|
||||
"Please check whether the current user has permission to this directory or modify the configuration file:{} jpom.path in is the path where the directory can be created", path, extConfigPath), e);
|
||||
System.exit(-1);
|
||||
}
|
||||
FileUtil.del(file);
|
||||
log.info("Jpom[{}] Current data path:{} External configuration file path:{}", JpomManifest.getInstance().getVersion(), path, extConfigPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更新包文件状态
|
||||
*/
|
||||
private void checkUpdate() {
|
||||
File runFile = JpomManifest.getRunPath().getParentFile();
|
||||
String upgrade = FileUtil.file(runFile, ConfigBean.UPGRADE).getAbsolutePath();
|
||||
JSONObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = (JSONObject) JsonFileUtil.readJson(upgrade);
|
||||
} catch (FileNotFoundException ignored) {
|
||||
}
|
||||
if (jsonObject != null) {
|
||||
String beforeJar = jsonObject.getString("beforeJar");
|
||||
if (StrUtil.isNotEmpty(beforeJar)) {
|
||||
File beforeJarFile = FileUtil.file(runFile, beforeJar);
|
||||
if (beforeJarFile.exists()) {
|
||||
File oldJars = JpomManifest.getOldJarsPath();
|
||||
FileUtil.mkdir(oldJars);
|
||||
FileUtil.move(beforeJarFile, oldJars, true);
|
||||
log.info("备份旧程序包:" + beforeJar);
|
||||
}
|
||||
}
|
||||
}
|
||||
clearOldJar();
|
||||
// windows 备份日志
|
||||
// if (SystemUtil.getOsInfo().isWindows()) {
|
||||
// boolean logBack = jsonObject.getBooleanValue("logBack");
|
||||
// String oldLogName = jsonObject.getString("oldLogName");
|
||||
// if (logBack && StrUtil.isNotEmpty(oldLogName)) {
|
||||
// File scriptFile = JpomManifest.getScriptFile();
|
||||
// File oldLog = FileUtil.file(scriptFile.getParentFile(), oldLogName);
|
||||
// if (oldLog.exists()) {
|
||||
// File logBackDir = FileUtil.file(scriptFile.getParentFile(), "log");
|
||||
// FileUtil.move(oldLog, logBackDir, true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private static void clearOldJar() {
|
||||
File oldJars = JpomManifest.getOldJarsPath();
|
||||
List<File> files = FileUtil.loopFiles(oldJars, 1, file -> StrUtil.endWith(file.getName(), FileUtil.JAR_FILE_EXT, true));
|
||||
if (CollUtil.isEmpty(files)) {
|
||||
return;
|
||||
}
|
||||
// 排序
|
||||
files.sort((o1, o2) -> FileUtil.lastModifiedTime(o2).compareTo(FileUtil.lastModifiedTime(o1)));
|
||||
// 截取
|
||||
int size = CollUtil.size(files);
|
||||
files = CollUtil.sub(files, ExtConfigBean.getInstance().getOldJarsCount(), size);
|
||||
// 删除文件
|
||||
files.forEach(FileUtil::del);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
// 启动最后的预加载
|
||||
if (event instanceof ApplicationReadyEvent) {
|
||||
//
|
||||
checkPath();
|
||||
JpomManifest jpomManifest = JpomManifest.getInstance();
|
||||
ConfigBean instance = ConfigBean.getInstance();
|
||||
// 清理旧进程新文件
|
||||
File dataDir = FileUtil.file(instance.getDataPath());
|
||||
List<File> files = FileUtil.loopFiles(dataDir, 1, pathname -> pathname.getName().startsWith("pid."));
|
||||
files.forEach(FileUtil::del);
|
||||
try {
|
||||
this.lockFile(jpomManifest.getPid());
|
||||
} catch (IOException e) {
|
||||
log.error("lockFile", e);
|
||||
}
|
||||
// 写入Jpom 信息 、 写入全局信息
|
||||
File appJpomFile = instance.getApplicationJpomInfo(JpomApplication.getAppType());
|
||||
FileUtil.writeString(jpomManifest.toString(), appJpomFile, CharsetUtil.CHARSET_UTF_8);
|
||||
// 检查更新文件
|
||||
checkUpdate();
|
||||
//
|
||||
if (ApplicationEventLoad.class.isAssignableFrom(JpomApplication.getAppClass())) {
|
||||
ApplicationEventLoad eventLoad = (ApplicationEventLoad) SpringUtil.getBean(JpomApplication.getAppClass());
|
||||
eventLoad.applicationLoad();
|
||||
}
|
||||
Console.log("Jpom Successful start preparation. start loading module");
|
||||
} else if (event instanceof ContextClosedEvent) {
|
||||
// 应用关闭
|
||||
this.unLockFile();
|
||||
//
|
||||
ConfigBean instance = ConfigBean.getInstance();
|
||||
FileUtil.del(instance.getPidFile());
|
||||
//
|
||||
File appJpomFile = instance.getApplicationJpomInfo(JpomApplication.getAppType());
|
||||
FileUtil.del(appJpomFile);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void statLoad() {
|
||||
ThreadUtil.execute(() -> {
|
||||
// 加载定时器
|
||||
Map<String, ICron> cronMap = SpringUtil.getApplicationContext().getBeansOfType(ICron.class);
|
||||
cronMap.forEach((name, iCron) -> {
|
||||
int startCron = iCron.startCron();
|
||||
if (startCron > 0) {
|
||||
log.debug("{} scheduling has been started:{}", name, startCron);
|
||||
}
|
||||
});
|
||||
Map<String, IAsyncLoad> asyncLoadMap = SpringUtil.getApplicationContext().getBeansOfType(IAsyncLoad.class);
|
||||
asyncLoadMap.forEach((name, asyncLoad) -> asyncLoad.startLoad());
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 解锁进程文件
|
||||
*/
|
||||
private void unLockFile() {
|
||||
if (lock != null) {
|
||||
try {
|
||||
lock.release();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
IoUtil.close(lock);
|
||||
IoUtil.close(fileChannel);
|
||||
IoUtil.close(fileOutputStream);
|
||||
}
|
||||
/**
|
||||
* 输出启动成功的 日志
|
||||
*/
|
||||
private void success() {
|
||||
Type type = JpomManifest.getInstance().getType();
|
||||
int port = ConfigBean.getInstance().getPort();
|
||||
String localhostStr = NetUtil.getLocalhostStr();
|
||||
String url = StrUtil.format("http://{}:{}", localhostStr, port);
|
||||
if (type == Type.Server) {
|
||||
log.info("{} Successfully started,Can use happily => {} 【The current address is for reference only】", type, url);
|
||||
} else if (type == Type.Agent) {
|
||||
log.info("{} Successfully started,Please go to the server to configure and use,Current node address => {} 【The current address is for reference only】", type, url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 锁住进程文件
|
||||
*
|
||||
* @throws IOException IO
|
||||
*/
|
||||
private void lockFile(long pid) throws IOException {
|
||||
this.fileOutputStream = new FileOutputStream(ConfigBean.getInstance().getPidFile(), true);
|
||||
this.fileOutputStream.write(StrUtil.bytes("Jpom pid:" + pid, CharsetUtil.CHARSET_UTF_8));
|
||||
this.fileOutputStream.flush();
|
||||
this.fileChannel = fileOutputStream.getChannel();
|
||||
while (true) {
|
||||
try {
|
||||
lock = fileChannel.lock();
|
||||
break;
|
||||
} catch (OverlappingFileLockException | IOException e) {
|
||||
log.warn("获取进程文件锁失败:" + e.getMessage());
|
||||
}
|
||||
ThreadUtil.sleep(100);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 判断是否重复运行
|
||||
*/
|
||||
|
||||
private static void checkPath() {
|
||||
String path = ExtConfigBean.getInstance().getPath();
|
||||
String extConfigPath = null;
|
||||
try {
|
||||
extConfigPath = ExtConfigBean.getResource().getURL().toString();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
File file = FileUtil.file(path);
|
||||
try {
|
||||
FileUtil.mkdir(file);
|
||||
file = FileUtil.createTempFile("jpom", ".temp", file, true);
|
||||
} catch (Exception e) {
|
||||
log.error(StrUtil.format("Jpom Failed to create data directory, directory location:{}," +
|
||||
"Please check whether the current user has permission to this directory or modify the configuration file:{} jpom.path in is the path where the directory can be created", path, extConfigPath), e);
|
||||
System.exit(-1);
|
||||
}
|
||||
FileUtil.del(file);
|
||||
Console.log("Jpom[{}] Current data path:{} External configuration file path:{}", JpomManifest.getInstance().getVersion(), path, extConfigPath);
|
||||
}
|
||||
private void checkDuplicateRun() {
|
||||
try {
|
||||
Class<?> appClass = JpomApplication.getAppClass();
|
||||
String pid = String.valueOf(JpomManifest.getInstance().getPid());
|
||||
Integer mainClassPid = JvmUtil.findMainClassPid(appClass.getName());
|
||||
if (mainClassPid == null || pid.equals(ObjectUtil.toString(mainClassPid))) {
|
||||
return;
|
||||
}
|
||||
log.warn("The Jpom program recommends that only one corresponding program be run on a machine:" + JpomApplication.getAppType() + " pid:" + mainClassPid);
|
||||
} catch (Exception e) {
|
||||
log.error("检查异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更新包文件状态
|
||||
*/
|
||||
private static void checkUpdate() {
|
||||
File runFile = JpomManifest.getRunPath().getParentFile();
|
||||
String upgrade = FileUtil.file(runFile, ConfigBean.UPGRADE).getAbsolutePath();
|
||||
JSONObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = (JSONObject) JsonFileUtil.readJson(upgrade);
|
||||
} catch (FileNotFoundException ignored) {
|
||||
}
|
||||
if (jsonObject != null) {
|
||||
String beforeJar = jsonObject.getString("beforeJar");
|
||||
if (StrUtil.isNotEmpty(beforeJar)) {
|
||||
File beforeJarFile = FileUtil.file(runFile, beforeJar);
|
||||
if (beforeJarFile.exists()) {
|
||||
File oldJars = JpomManifest.getOldJarsPath();
|
||||
FileUtil.mkdir(oldJars);
|
||||
FileUtil.move(beforeJarFile, oldJars, true);
|
||||
log.info("备份旧程序包:" + beforeJar);
|
||||
}
|
||||
}
|
||||
}
|
||||
clearOldJar();
|
||||
// windows 备份日志
|
||||
// if (SystemUtil.getOsInfo().isWindows()) {
|
||||
// boolean logBack = jsonObject.getBooleanValue("logBack");
|
||||
// String oldLogName = jsonObject.getString("oldLogName");
|
||||
// if (logBack && StrUtil.isNotEmpty(oldLogName)) {
|
||||
// File scriptFile = JpomManifest.getScriptFile();
|
||||
// File oldLog = FileUtil.file(scriptFile.getParentFile(), oldLogName);
|
||||
// if (oldLog.exists()) {
|
||||
// File logBackDir = FileUtil.file(scriptFile.getParentFile(), "log");
|
||||
// FileUtil.move(oldLog, logBackDir, true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private static void clearOldJar() {
|
||||
File oldJars = JpomManifest.getOldJarsPath();
|
||||
List<File> files = FileUtil.loopFiles(oldJars, 1, file -> StrUtil.endWith(file.getName(), FileUtil.JAR_FILE_EXT, true));
|
||||
if (CollUtil.isEmpty(files)) {
|
||||
return;
|
||||
}
|
||||
// 排序
|
||||
files.sort((o1, o2) -> FileUtil.lastModifiedTime(o2).compareTo(FileUtil.lastModifiedTime(o1)));
|
||||
// 截取
|
||||
int size = CollUtil.size(files);
|
||||
files = CollUtil.sub(files, ExtConfigBean.getInstance().getOldJarsCount(), size);
|
||||
// 删除文件
|
||||
files.forEach(FileUtil::del);
|
||||
}
|
||||
private void reqXssLog() {
|
||||
if (!ExtConfigBean.getInstance().isConsoleLogReqXss()) {
|
||||
// 不在控制台记录请求日志信息
|
||||
DefaultSystemLog.setLogCallback(new DefaultSystemLog.LogCallback() {
|
||||
@Override
|
||||
public void log(DefaultSystemLog.LogType type, Object... log) {
|
||||
//
|
||||
if (type == DefaultSystemLog.LogType.REQUEST_ERROR) {
|
||||
JpomApplicationEvent.log.info(Arrays.toString(log));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logStart(HttpServletRequest request, String id, String url, HttpMethod httpMethod, String ip, Map<String, String> parameters, Map<String, String> header) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logError(HttpServletResponse response, String id, int status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logTimeOut(HttpServletResponse response, String id, long time) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void clearTemp() {
|
||||
File file = ConfigBean.getInstance().getTempPath();
|
||||
/**
|
||||
* @author Hotstrip
|
||||
* use Hutool's FileUtil.del method just put file as param not file's path
|
||||
* or else, may be return Accessdenied exception
|
||||
*/
|
||||
try {
|
||||
FileUtil.del(file);
|
||||
} catch (Exception e) {
|
||||
// Try again jzy 2021-07-31
|
||||
log.warn("Attempt to delete temporary folder failed, try to handle read-only permission:{}", e.getMessage());
|
||||
List<File> files = FileUtil.loopFiles(file);
|
||||
long count = files.stream().map(file12 -> file12.setWritable(true)).filter(aBoolean -> aBoolean).count();
|
||||
log.warn("Cumulative number of files in temporary folder: {}, number of successful processing:{}", CollUtil.size(files), count);
|
||||
try {
|
||||
FileUtil.del(file.toPath());
|
||||
} catch (Exception e1) {
|
||||
e1.addSuppressed(e);
|
||||
boolean causedBy = ExceptionUtil.isCausedBy(e1, AccessDeniedException.class);
|
||||
if (causedBy) {
|
||||
log.error("清除临时文件失败,请手动清理:" + FileUtil.getAbsolutePath(file), e);
|
||||
return;
|
||||
}
|
||||
log.error("清除临时文件失败,请检查目录:" + FileUtil.getAbsolutePath(file), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.GlobalHeaders;
|
||||
import cn.hutool.http.Header;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.JpomApplication;
|
||||
|
188
modules/common/src/main/java/io/jpom/common/JsonMessage.java
Normal file
188
modules/common/src/main/java/io/jpom/common/JsonMessage.java
Normal file
@ -0,0 +1,188 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.common;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.serializer.ToStringSerializer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* 通用的json 数据格式
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @since 2017/2/6.
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JsonMessage<T> implements Serializable {
|
||||
public static final String CODE = "code";
|
||||
public static final String MSG = "msg";
|
||||
public static final String DATA = "data";
|
||||
|
||||
static {
|
||||
// long 类型自动转String
|
||||
SerializeConfig serializeConfig = SerializeConfig.globalInstance;
|
||||
serializeConfig.put(Long.class, ToStringSerializer.instance);
|
||||
serializeConfig.put(long.class, ToStringSerializer.instance);
|
||||
serializeConfig.put(BigInteger.class, ToStringSerializer.instance);
|
||||
serializeConfig.put(Long.TYPE, ToStringSerializer.instance);
|
||||
}
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
public JsonMessage() {
|
||||
}
|
||||
|
||||
public JsonMessage(int code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public JsonMessage(int code, String msg) {
|
||||
this(code, msg, null);
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将data 转换为对应实体
|
||||
*
|
||||
* @param tClass 类
|
||||
* @param <E> 泛型
|
||||
* @return Object
|
||||
*/
|
||||
public <E> E getData(Class<E> tClass) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
if (tClass.isAssignableFrom(data.getClass())) {
|
||||
return (E) data;
|
||||
}
|
||||
return JSONObject.parseObject(data.toString(), tClass);
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return json
|
||||
* @author jiangzeyin
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
// TODO Auto-generated method stub
|
||||
return JSONObject.toJSONString(this);
|
||||
}
|
||||
|
||||
public JSONObject toJson() {
|
||||
return (JSONObject) JSONObject.toJSON(this);
|
||||
}
|
||||
|
||||
public String dataToString() {
|
||||
T object = getData();
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出格式化后的json 字符串
|
||||
*
|
||||
* @return 字符串
|
||||
*/
|
||||
public String toFormatJson() {
|
||||
return JSONObject.toJSONString(this, SerializerFeature.PrettyFormat);
|
||||
}
|
||||
|
||||
public static JSONObject toJson(int code, String msg) {
|
||||
return toJson(code, msg, null);
|
||||
}
|
||||
|
||||
public static JSONObject toJson(int code, String msg, Object data) {
|
||||
JsonMessage<Object> jsonMessage = new JsonMessage<>(code, msg, data);
|
||||
return jsonMessage.toJson();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @return json
|
||||
* @author jiangzeyin
|
||||
*/
|
||||
public static String getString(int code, String msg) {
|
||||
return getString(code, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code code
|
||||
* @param msg msg
|
||||
* @param data data
|
||||
* @return json
|
||||
* @author jiangzeyin
|
||||
*/
|
||||
public static String getString(int code, String msg, Object data) {
|
||||
return toJson(code, msg, data).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* json字符串转 jsonMessage对象
|
||||
*
|
||||
* @param json json字符串
|
||||
* @param tClass data类型
|
||||
* @param <T> 泛型
|
||||
* @return jsonMessage
|
||||
*/
|
||||
public static <T> JsonMessage<T> toJsonMessage(String json, Class<T> tClass) {
|
||||
JsonMessage<T> jsonMessage = JSONObject.parseObject(json, JsonMessage.class);
|
||||
// 自动转换
|
||||
T data = jsonMessage.getData(tClass);
|
||||
jsonMessage.setData(data);
|
||||
return jsonMessage;
|
||||
}
|
||||
}
|
@ -32,7 +32,6 @@ import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.model.BaseJsonModel;
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
package io.jpom.controller;
|
||||
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController;
|
||||
import org.springframework.boot.web.servlet.error.ErrorAttributes;
|
||||
|
@ -147,7 +147,7 @@ public class PluginFactory implements ApplicationContextInitializer<Configurable
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
init();
|
||||
//init();
|
||||
// 扫描插件 实现
|
||||
Set<Class<?>> classes = ClassUtil.scanPackage("io.jpom", IPlugin.class::isAssignableFrom);
|
||||
List<PluginItemWrap> pluginItemWraps = classes
|
||||
|
@ -30,7 +30,6 @@ import io.jpom.JpomApplication;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.Type;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.config.ConfigFileApplicationListener;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
@ -92,11 +91,6 @@ public class ConfigBean {
|
||||
*/
|
||||
@Value("${server.port}")
|
||||
private int port;
|
||||
/**
|
||||
* 环境
|
||||
*/
|
||||
@Value("${" + ConfigFileApplicationListener.ACTIVE_PROFILES_PROPERTY + "}")
|
||||
private String active;
|
||||
/**
|
||||
* 数据目录缓存大小
|
||||
*/
|
||||
@ -104,6 +98,12 @@ public class ConfigBean {
|
||||
|
||||
private volatile static ConfigBean configBean;
|
||||
|
||||
private final ExtConfigBean extConfigBean;
|
||||
|
||||
public ConfigBean(ExtConfigBean extConfigBean) {
|
||||
this.extConfigBean = extConfigBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单利模式
|
||||
*
|
||||
@ -130,7 +130,7 @@ public class ConfigBean {
|
||||
* @return 文件夹路径
|
||||
*/
|
||||
public String getDataPath() {
|
||||
String dataPath = FileUtil.normalize(ExtConfigBean.getInstance().getPath() + StrUtil.SLASH + DATA);
|
||||
String dataPath = FileUtil.normalize(extConfigBean.getPath() + StrUtil.SLASH + DATA);
|
||||
FileUtil.mkdir(dataPath);
|
||||
return dataPath;
|
||||
}
|
||||
@ -165,26 +165,13 @@ public class ConfigBean {
|
||||
return FileUtil.normalize(dataPath + StrUtil.SLASH + ConfigBean.AUTHORIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为 pro 模式运行
|
||||
*
|
||||
* @return pro
|
||||
*/
|
||||
public boolean isPro() {
|
||||
return StrUtil.equals(this.active, "pro");
|
||||
}
|
||||
|
||||
public String getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取临时文件存储路径
|
||||
*
|
||||
* @return file
|
||||
*/
|
||||
public File getTempPath() {
|
||||
File file = new File(ConfigBean.getInstance().getDataPath());
|
||||
File file = new File(this.getDataPath());
|
||||
file = FileUtil.file(file, "temp");
|
||||
FileUtil.mkdir(file);
|
||||
return file;
|
||||
|
@ -24,6 +24,7 @@ package io.jpom.system;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -33,13 +34,16 @@ import io.jpom.JpomApplication;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.config.ConfigFileApplicationListener;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 外部资源配置
|
||||
@ -59,11 +63,7 @@ public class ExtConfigBean {
|
||||
*/
|
||||
@Value("${consoleLog.reqXss:true}")
|
||||
private boolean consoleLogReqXss;
|
||||
/**
|
||||
* 请求响应
|
||||
*/
|
||||
@Value("${consoleLog.reqResponse:true}")
|
||||
private boolean consoleLogReqResponse;
|
||||
|
||||
|
||||
/**
|
||||
* 日志文件的编码格式,如果没有指定就自动识别,自动识别可能出现不准确的情况
|
||||
@ -117,10 +117,6 @@ public class ExtConfigBean {
|
||||
return logFileCharset;
|
||||
}
|
||||
|
||||
public boolean isConsoleLogReqResponse() {
|
||||
return consoleLogReqResponse;
|
||||
}
|
||||
|
||||
public boolean isConsoleLogReqXss() {
|
||||
return consoleLogReqXss;
|
||||
}
|
||||
@ -136,16 +132,16 @@ public class ExtConfigBean {
|
||||
if (resource != null) {
|
||||
return resource;
|
||||
}
|
||||
File file = JpomManifest.getRunPath();
|
||||
if (file.isFile()) {
|
||||
file = file.getParentFile().getParentFile();
|
||||
file = FileUtil.file(file, FILE_NAME);
|
||||
if (file.exists() && file.isFile()) {
|
||||
resource = new FileSystemResource(file);
|
||||
return ExtConfigBean.resource;
|
||||
}
|
||||
}
|
||||
resource = new ClassPathResource("/bin/" + FILE_NAME);
|
||||
String property = cn.hutool.extra.spring.SpringUtil.getApplicationContext().getEnvironment().getProperty(ConfigFileApplicationListener.CONFIG_LOCATION_PROPERTY);
|
||||
Resource configResource = Opt.ofBlankAble(property)
|
||||
.map(FileSystemResource::new)
|
||||
.flatMap((Function<Resource, Opt<Resource>>) resource -> resource.exists() ? Opt.of(resource) : Opt.empty())
|
||||
.orElseGet(() -> {
|
||||
ClassPathResource classPathResource = new ClassPathResource("application.yml");
|
||||
return classPathResource.exists() ? classPathResource : new ClassPathResource("/config_default/application.yml");
|
||||
});
|
||||
Assert.state(configResource.exists(), "均未找到配置文件");
|
||||
resource = configResource;
|
||||
return ExtConfigBean.resource;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
package io.jpom.system;
|
||||
|
||||
import ch.qos.logback.core.PropertyDefinerBase;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @since 2022/12/7
|
||||
*/
|
||||
public class LogbackConfig extends PropertyDefinerBase {
|
||||
|
||||
public static String getPath() {
|
||||
String jpomLog = SystemUtil.get("JPOM_LOG");
|
||||
Assert.hasText(jpomLog, "没有配置 JPOM_LOG");
|
||||
return jpomLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyValue() {
|
||||
String jpomLog = SystemUtil.get("JPOM_LOG");
|
||||
jpomLog = Opt.ofBlankAble(jpomLog).orElseGet(() -> {
|
||||
String locationPath = ClassUtil.getLocationPath(LogbackConfig.class);
|
||||
File file = FileUtil.file(FileUtil.getParent(locationPath, 2), "logs");
|
||||
String path = FileUtil.getAbsolutePath(file);
|
||||
System.out.println(path);
|
||||
return path;
|
||||
});
|
||||
SystemUtil.set("JPOM_LOG", jpomLog);
|
||||
return jpomLog;
|
||||
}
|
||||
}
|
@ -22,22 +22,17 @@
|
||||
*/
|
||||
package io.jpom.system;
|
||||
|
||||
import ch.qos.logback.core.PropertyDefinerBase;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.jiangzeyin.common.interceptor.BaseCallbackController;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.util.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 自动记录日志
|
||||
@ -48,63 +43,38 @@ import java.io.File;
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WebAopLog extends PropertyDefinerBase {
|
||||
public class WebAopLog {
|
||||
|
||||
private static volatile AopLogInterface aopLogInterface;
|
||||
private final Collection<AopLogInterface> aopLogInterface;
|
||||
|
||||
synchronized public static void setAopLogInterface(AopLogInterface aopLogInterface) {
|
||||
WebAopLog.aopLogInterface = aopLogInterface;
|
||||
}
|
||||
public WebAopLog() {
|
||||
this.aopLogInterface = SpringUtil.getBeansOfType(AopLogInterface.class).values();
|
||||
}
|
||||
|
||||
@Pointcut("execution(public * io.jpom.controller..*.*(..))")
|
||||
public void webLog() {
|
||||
//
|
||||
}
|
||||
@Pointcut("execution(public * io.jpom.controller..*.*(..))")
|
||||
public void webLog() {
|
||||
//
|
||||
}
|
||||
|
||||
@Around(value = "webLog()", argNames = "joinPoint")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
// 接收到请求,记录请求内容
|
||||
boolean consoleLogReqResponse = ExtConfigBean.getInstance().isConsoleLogReqResponse();
|
||||
Object proceed;
|
||||
Object logResult = null;
|
||||
try {
|
||||
if (aopLogInterface != null) {
|
||||
aopLogInterface.before(joinPoint);
|
||||
}
|
||||
proceed = joinPoint.proceed();
|
||||
logResult = proceed;
|
||||
} catch (Throwable e) {
|
||||
logResult = e;
|
||||
throw e;
|
||||
} finally {
|
||||
if (aopLogInterface != null) {
|
||||
aopLogInterface.afterReturning(logResult);
|
||||
}
|
||||
}
|
||||
if (consoleLogReqResponse && logResult != null) {
|
||||
log.info(BaseCallbackController.getRequestAttributes().getRequest().getRequestURI() + " :" + logResult);
|
||||
}
|
||||
return proceed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyValue() {
|
||||
String path = StringUtil.getArgsValue(JpomApplication.getArgs(), "jpom.log");
|
||||
if (StrUtil.isEmpty(path)) {
|
||||
//
|
||||
File file = JpomManifest.getRunPath();
|
||||
if (file.isFile()) {
|
||||
// jar 运行模式
|
||||
file = file.getParentFile().getParentFile();
|
||||
} else {
|
||||
// 本地调试模式 @author jzy 2021-08-02 程序运行时候不影响打包
|
||||
file = FileUtil.file(FileUtil.getParent(file, 2), "log");
|
||||
Console.log("log file save path :" + FileUtil.getAbsolutePath(file));
|
||||
}
|
||||
path = FileUtil.getAbsolutePath(file);
|
||||
}
|
||||
// 配置默认日志路径
|
||||
// DefaultSystemLog.configPath(path, false);
|
||||
return path;
|
||||
}
|
||||
@Around(value = "webLog()", argNames = "joinPoint")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
// 接收到请求,记录请求内容
|
||||
Object proceed;
|
||||
Object logResult = null;
|
||||
ServletRequestAttributes requestAttributes = BaseCallbackController.getRequestAttributes();
|
||||
try {
|
||||
aopLogInterface.forEach(aopLogInterface -> aopLogInterface.before(joinPoint));
|
||||
proceed = joinPoint.proceed();
|
||||
logResult = proceed;
|
||||
log.debug("{} {}", requestAttributes.getRequest().getRequestURI(), proceed);
|
||||
} catch (Throwable e) {
|
||||
log.debug("{}", requestAttributes.getRequest().getRequestURI(), e);
|
||||
logResult = e;
|
||||
throw e;
|
||||
} finally {
|
||||
Object finalLogResult = logResult;
|
||||
aopLogInterface.forEach(aopLogInterface -> aopLogInterface.afterReturning(finalLogResult));
|
||||
}
|
||||
return proceed;
|
||||
}
|
||||
}
|
||||
|
@ -1,136 +1,59 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.system.init;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
import cn.jiangzeyin.common.PreLoadClass;
|
||||
import cn.jiangzeyin.common.PreLoadMethod;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.system.ConfigBean;
|
||||
import io.jpom.system.ExtConfigBean;
|
||||
import io.jpom.util.JvmUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.nio.file.AccessDeniedException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据目录权限检查
|
||||
*
|
||||
* @author jiangzeyin
|
||||
* @since 2019/3/26
|
||||
*/
|
||||
@PreLoadClass(value = Integer.MIN_VALUE)
|
||||
@Slf4j
|
||||
public class CheckPath {
|
||||
|
||||
/**
|
||||
* 判断是否重复运行
|
||||
*/
|
||||
@PreLoadMethod(2)
|
||||
private static void checkDuplicateRun() {
|
||||
try {
|
||||
Class<?> appClass = JpomApplication.getAppClass();
|
||||
String pid = String.valueOf(JpomManifest.getInstance().getPid());
|
||||
Integer mainClassPid = JvmUtil.findMainClassPid(appClass.getName());
|
||||
if (mainClassPid == null || pid.equals(ObjectUtil.toString(mainClassPid))) {
|
||||
return;
|
||||
}
|
||||
log.warn("The Jpom program recommends that only one corresponding program be run on a machine:" + JpomApplication.getAppType() + " pid:" + mainClassPid);
|
||||
} catch (Exception e) {
|
||||
log.error("检查异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@PreLoadMethod(3)
|
||||
private static void reqXssLog() {
|
||||
if (!ExtConfigBean.getInstance().isConsoleLogReqXss()) {
|
||||
// 不在控制台记录请求日志信息
|
||||
DefaultSystemLog.setLogCallback(new DefaultSystemLog.LogCallback() {
|
||||
@Override
|
||||
public void log(DefaultSystemLog.LogType type, Object... log) {
|
||||
//
|
||||
if (type == DefaultSystemLog.LogType.REQUEST_ERROR) {
|
||||
CheckPath.log.info(Arrays.toString(log));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logStart(HttpServletRequest request, String id, String url, HttpMethod httpMethod, String ip, Map<String, String> parameters, Map<String, String> header) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logError(HttpServletResponse response, String id, int status) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logTimeOut(HttpServletResponse response, String id, long time) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@PreLoadMethod(4)
|
||||
private static void clearTemp() {
|
||||
File file = ConfigBean.getInstance().getTempPath();
|
||||
/**
|
||||
* @author Hotstrip
|
||||
* use Hutool's FileUtil.del method just put file as param not file's path
|
||||
* or else, may be return Accessdenied exception
|
||||
*/
|
||||
try {
|
||||
FileUtil.del(file);
|
||||
} catch (Exception e) {
|
||||
// Try again jzy 2021-07-31
|
||||
log.warn("Attempt to delete temporary folder failed, try to handle read-only permission:{}", e.getMessage());
|
||||
List<File> files = FileUtil.loopFiles(file);
|
||||
long count = files.stream().map(file12 -> file12.setWritable(true)).filter(aBoolean -> aBoolean).count();
|
||||
log.warn("Cumulative number of files in temporary folder: {}, number of successful processing:{}", CollUtil.size(files), count);
|
||||
try {
|
||||
FileUtil.del(file.toPath());
|
||||
} catch (Exception e1) {
|
||||
e1.addSuppressed(e);
|
||||
boolean causedBy = ExceptionUtil.isCausedBy(e1, AccessDeniedException.class);
|
||||
if (causedBy) {
|
||||
log.error("清除临时文件失败,请手动清理:" + FileUtil.getAbsolutePath(file), e);
|
||||
return;
|
||||
}
|
||||
log.error("清除临时文件失败,请检查目录:" + FileUtil.getAbsolutePath(file), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * The MIT License (MIT)
|
||||
// *
|
||||
// * Copyright (c) 2019 Code Technology Studio
|
||||
// *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// * this software and associated documentation files (the "Software"), to deal in
|
||||
// * the Software without restriction, including without limitation the rights to
|
||||
// * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// * the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// * subject to the following conditions:
|
||||
// *
|
||||
// * The above copyright notice and this permission notice shall be included in all
|
||||
// * copies or substantial portions of the Software.
|
||||
// *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// */
|
||||
//package io.jpom.system.init;
|
||||
//
|
||||
//import cn.hutool.core.collection.CollUtil;
|
||||
//import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
//import cn.hutool.core.io.FileUtil;
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import cn.jiangzeyin.common.DefaultSystemLog;
|
||||
//import cn.jiangzeyin.common.PreLoadClass;
|
||||
//import cn.jiangzeyin.common.PreLoadMethod;
|
||||
//import io.jpom.JpomApplication;
|
||||
//import io.jpom.common.JpomManifest;
|
||||
//import io.jpom.system.ConfigBean;
|
||||
//import io.jpom.system.ExtConfigBean;
|
||||
//import io.jpom.util.JvmUtil;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.http.HttpMethod;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.io.File;
|
||||
//import java.nio.file.AccessDeniedException;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * 数据目录权限检查
|
||||
// *
|
||||
// * @author jiangzeyin
|
||||
// * @since 2019/3/26
|
||||
// */
|
||||
//@PreLoadClass(value = Integer.MIN_VALUE)
|
||||
//@Slf4j
|
||||
//public class CheckPath {
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Code Technology Studio
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.jpom.system.init;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.PreLoadClass;
|
||||
import cn.jiangzeyin.common.PreLoadMethod;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import io.jpom.common.JpomManifest;
|
||||
import io.jpom.common.Type;
|
||||
import io.jpom.cron.IAsyncLoad;
|
||||
import io.jpom.cron.ICron;
|
||||
import io.jpom.system.ConfigBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author bwcx_jzy
|
||||
* @since Created Time 2021/8/2
|
||||
*/
|
||||
@PreLoadClass(value = Integer.MAX_VALUE)
|
||||
@Slf4j
|
||||
public class ConsoleStartSuccess {
|
||||
|
||||
|
||||
@PreLoadMethod(value = Integer.MAX_VALUE - 1)
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static void statLoad() {
|
||||
ThreadUtil.execute(() -> {
|
||||
// 加载定时器
|
||||
Map<String, ICron> cronMap = SpringUtil.getApplicationContext().getBeansOfType(ICron.class);
|
||||
cronMap.forEach((name, iCron) -> {
|
||||
int startCron = iCron.startCron();
|
||||
if (startCron > 0) {
|
||||
log.debug("{} scheduling has been started:{}", name, startCron);
|
||||
}
|
||||
});
|
||||
Map<String, IAsyncLoad> asyncLoadMap = SpringUtil.getApplicationContext().getBeansOfType(IAsyncLoad.class);
|
||||
asyncLoadMap.forEach((name, asyncLoad) -> asyncLoad.startLoad());
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出启动成功的 日志
|
||||
*/
|
||||
@PreLoadMethod(value = Integer.MAX_VALUE)
|
||||
private static void success() {
|
||||
Type type = JpomManifest.getInstance().getType();
|
||||
int port = ConfigBean.getInstance().getPort();
|
||||
String localhostStr = NetUtil.getLocalhostStr();
|
||||
String url = StrUtil.format("http://{}:{}", localhostStr, port);
|
||||
if (type == Type.Server) {
|
||||
Console.log("{} Successfully started,Can use happily => {} 【The current address is for reference only】", type, url);
|
||||
} else if (type == Type.Agent) {
|
||||
Console.log("{} Successfully started,Please go to the server to configure and use,Current node address => {} 【The current address is for reference only】", type, url);
|
||||
}
|
||||
}
|
||||
}
|
@ -31,7 +31,6 @@ import cn.hutool.core.lang.Tuple;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
|
||||
@ -116,58 +115,58 @@ public class FileUtils {
|
||||
// return arrayFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断路径是否满足jdk 条件
|
||||
*
|
||||
* @param path 路径
|
||||
* @return 判断存在java文件
|
||||
*/
|
||||
public static boolean isJdkPath(String path) {
|
||||
String fileName = getJdkJavaPath(path, false);
|
||||
File newPath = new File(fileName);
|
||||
return newPath.exists() && newPath.isFile();
|
||||
}
|
||||
// /**
|
||||
// * 判断路径是否满足jdk 条件
|
||||
// *
|
||||
// * @param path 路径
|
||||
// * @return 判断存在java文件
|
||||
// */
|
||||
// public static boolean isJdkPath(String path) {
|
||||
// String fileName = getJdkJavaPath(path, false);
|
||||
// File newPath = new File(fileName);
|
||||
// return newPath.exists() && newPath.isFile();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取java 文件路径
|
||||
*
|
||||
* @param path path
|
||||
* @param w 是否使用javaw
|
||||
* @return 完整路径
|
||||
*/
|
||||
public static String getJdkJavaPath(String path, boolean w) {
|
||||
String fileName;
|
||||
if (SystemUtil.getOsInfo().isWindows()) {
|
||||
fileName = w ? "javaw.exe" : "java.exe";
|
||||
} else {
|
||||
fileName = w ? "javaw" : "java";
|
||||
}
|
||||
File newPath = FileUtil.file(path, "bin", fileName);
|
||||
return FileUtil.getAbsolutePath(newPath);
|
||||
}
|
||||
// /**
|
||||
// * 获取java 文件路径
|
||||
// *
|
||||
// * @param path path
|
||||
// * @param w 是否使用javaw
|
||||
// * @return 完整路径
|
||||
// */
|
||||
// public static String getJdkJavaPath(String path, boolean w) {
|
||||
// String fileName;
|
||||
// if (SystemUtil.getOsInfo().isWindows()) {
|
||||
// fileName = w ? "javaw.exe" : "java.exe";
|
||||
// } else {
|
||||
// fileName = w ? "javaw" : "java";
|
||||
// }
|
||||
// File newPath = FileUtil.file(path, "bin", fileName);
|
||||
// return FileUtil.getAbsolutePath(newPath);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取jdk 版本
|
||||
*
|
||||
* @param path jdk 路径
|
||||
* @return 获取成功返回版本号
|
||||
*/
|
||||
public static String getJdkVersion(String path) {
|
||||
String newPath = getJdkJavaPath(path, false);
|
||||
if (path.contains(StrUtil.SPACE)) {
|
||||
newPath = String.format("\"%s\"", newPath);
|
||||
}
|
||||
String command = CommandUtil.execSystemCommand(newPath + " -version");
|
||||
String[] split = StrUtil.splitToArray(command, StrUtil.LF);
|
||||
if (split == null || split.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
String[] strings = StrUtil.splitToArray(split[0], "\"");
|
||||
if (strings == null || strings.length <= 1) {
|
||||
return null;
|
||||
}
|
||||
return strings[1];
|
||||
}
|
||||
// /**
|
||||
// * 获取jdk 版本
|
||||
// *
|
||||
// * @param path jdk 路径
|
||||
// * @return 获取成功返回版本号
|
||||
// */
|
||||
// public static String getJdkVersion(String path) {
|
||||
// String newPath = getJdkJavaPath(path, false);
|
||||
// if (path.contains(StrUtil.SPACE)) {
|
||||
// newPath = String.format("\"%s\"", newPath);
|
||||
// }
|
||||
// String command = CommandUtil.execSystemCommand(newPath + " -version");
|
||||
// String[] split = StrUtil.splitToArray(command, StrUtil.LF);
|
||||
// if (split == null || split.length <= 0) {
|
||||
// return null;
|
||||
// }
|
||||
// String[] strings = StrUtil.splitToArray(split[0], "\"");
|
||||
// if (strings == null || strings.length <= 1) {
|
||||
// return null;
|
||||
// }
|
||||
// return strings[1];
|
||||
// }
|
||||
|
||||
/**
|
||||
* 读取 日志文件
|
||||
|
@ -1,3 +1,2 @@
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=io.jpom.system.ExtConfigEnvironmentPostProcessor
|
||||
org.springframework.context.ApplicationListener=\
|
||||
io.jpom.JpomLogo
|
||||
org.springframework.context.ApplicationContextInitializer=io.jpom.plugin.PluginFactory
|
||||
org.springframework.context.ApplicationListener=io.jpom.plugin.PluginFactory
|
||||
|
@ -1,7 +0,0 @@
|
||||
# spring 相关配置
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
# 上传文件大小限制
|
||||
max-request-size: 2GB
|
||||
max-file-size: 1GB
|
@ -1,183 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Code Technology Studio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
-->
|
||||
<configuration debug="false">
|
||||
<!--动态定义日志路径-->
|
||||
<define name="logPath" class="io.jpom.system.WebAopLog"/>
|
||||
|
||||
<appender name="consoleInfo" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>INFO</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern><![CDATA[%date %level [%thread] %logger{10} [%file:%line]- x:\(%X\) %msg %n]]></pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="consoleError" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern><![CDATA[%date %level [%thread] %logger{10} [%file:%line]- x:\(%X\) %msg %n]]></pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="consoleWarn" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>warn</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern><![CDATA[%date %level [%thread] %logger{10} [%file:%line]- x:\(%X\) %msg%n]]></pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="consoleDebug" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>DEBUG</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern><![CDATA[%date %level [%thread] %logger{10} [%file:%line]- x:\(%X\) %msg %n]]></pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="errorFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${logPath}/error/systemError.log</File>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
<!-- 每天一归档 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${logPath}/error/systemError-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<!-- 单个日志文件最多 100MB, 30天的日志周期,最大不能超过10GB -->
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
<maxHistory>10</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<appender name="infoFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${logPath}/info.log</File>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>info</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
<!-- 每天一归档 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${logPath}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<!-- 单个日志文件最多 100MB, 30天的日志周期,最大不能超过10GB -->
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
<maxHistory>10</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<appender name="warnFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${logPath}/warn.log</File>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>warn</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
<!-- 每天一归档 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${logPath}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<!-- 单个日志文件最多 100MB, 30天的日志周期,最大不能超过10GB -->
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
<maxHistory>10</maxHistory>
|
||||
<totalSizeCap>1GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<springProfile name="dev">
|
||||
<root level="debug">
|
||||
<appender-ref ref="errorFileAppender"/>
|
||||
<appender-ref ref="infoFileAppender"/>
|
||||
<appender-ref ref="warnFileAppender"/>
|
||||
<appender-ref ref="consoleInfo"/>
|
||||
<appender-ref ref="consoleError"/>
|
||||
<appender-ref ref="consoleWarn"/>
|
||||
</root>
|
||||
<logger name="io.jpom" level="debug" additivity="true">
|
||||
<appender-ref ref="consoleDebug"/>
|
||||
</logger>
|
||||
<logger name="cn.jiangzeyin" level="debug" additivity="true">
|
||||
<appender-ref ref="consoleDebug"/>
|
||||
</logger>
|
||||
<logger name="cn.hutool.db.sql" level="debug" additivity="true">
|
||||
<appender-ref ref="consoleDebug"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="local">
|
||||
<root level="debug">
|
||||
<appender-ref ref="errorFileAppender"/>
|
||||
<appender-ref ref="infoFileAppender"/>
|
||||
<appender-ref ref="warnFileAppender"/>
|
||||
<appender-ref ref="consoleInfo"/>
|
||||
<appender-ref ref="consoleError"/>
|
||||
<appender-ref ref="consoleWarn"/>
|
||||
</root>
|
||||
<logger name="io.jpom" level="debug" additivity="true">
|
||||
<appender-ref ref="consoleDebug"/>
|
||||
</logger>
|
||||
<logger name="cn.jiangzeyin" level="debug" additivity="true">
|
||||
<appender-ref ref="consoleDebug"/>
|
||||
</logger>
|
||||
<logger name="cn.hutool.db.sql" level="debug" additivity="true">
|
||||
<appender-ref ref="consoleDebug"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="pro">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="errorFileAppender"/>
|
||||
<appender-ref ref="warnFileAppender"/>
|
||||
<appender-ref ref="consoleWarn"/>
|
||||
<appender-ref ref="consoleError"/>
|
||||
<!-- <appender-ref ref="consoleInfo"/>-->
|
||||
</root>
|
||||
</springProfile>
|
||||
</configuration>
|
@ -127,33 +127,6 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<!-- 是否指定项目classpath下的依赖 -->
|
||||
<addClasspath>true</addClasspath>
|
||||
<!-- 指定依赖的时候声明前缀 -->
|
||||
<classpathPrefix>./</classpathPrefix>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<!-- 项目版本号 -->
|
||||
<Jpom-Project-Version>${project.version}</Jpom-Project-Version>
|
||||
<!-- 打包时间 -->
|
||||
<Jpom-Timestamp>${maven.build.timestamp}</Jpom-Timestamp>
|
||||
<Jpom-Type>${project.artifactId}</Jpom-Type>
|
||||
<Implementation-URL>https://gitee.com/dromara/Jpom</Implementation-URL>
|
||||
<Jpom-Min-Version>${jpom-min-version}</Jpom-Min-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<!--版权文件,更新日志-->
|
||||
<resource>
|
||||
@ -179,6 +152,37 @@
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<!-- 是否指定项目classpath下的依赖 -->
|
||||
<addClasspath>true</addClasspath>
|
||||
<!-- 指定依赖的时候声明前缀 -->
|
||||
<classpathPrefix>./</classpathPrefix>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<!-- 项目版本号 -->
|
||||
<Jpom-Project-Version>${project.version}</Jpom-Project-Version>
|
||||
<!-- 打包时间 -->
|
||||
<Jpom-Timestamp>${maven.build.timestamp}</Jpom-Timestamp>
|
||||
<Jpom-Type>${project.artifactId}</Jpom-Type>
|
||||
<Implementation-URL>https://gitee.com/dromara/Jpom</Implementation-URL>
|
||||
<Jpom-Min-Version>${jpom-min-version}</Jpom-Min-Version>
|
||||
</manifestEntries>
|
||||
<addMavenDescriptor>true</addMavenDescriptor>
|
||||
</archive>
|
||||
<excludes>
|
||||
<exclude>logback.xml</exclude>
|
||||
<exclude>application.yml</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
@ -203,7 +207,7 @@
|
||||
<configuration>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<descriptors>
|
||||
<descriptor>script/release.xml</descriptor>
|
||||
<descriptor>${basedir}/src/main/assembly/release.xml</descriptor>
|
||||
</descriptors>
|
||||
<outputDirectory>target</outputDirectory>
|
||||
</configuration>
|
||||
@ -268,16 +272,5 @@
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>jna-mac</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>5.11.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Code Technology Studio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
-->
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||
<id>release</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
<format>zip</format>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
|
||||
<fileSets>
|
||||
<!-- 打包Jpom 管理命令文件-->
|
||||
<fileSet>
|
||||
<directory>script/</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>Server.sh</include>
|
||||
</includes>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
|
||||
<fileSet>
|
||||
<directory>script/</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>Server.bat</include>
|
||||
</includes>
|
||||
<lineEnding>dos</lineEnding>
|
||||
</fileSet>
|
||||
<!--复制外部配置文件-->
|
||||
<fileSet>
|
||||
<directory>src/main/resources/bin/</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>extConfig.yml</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<!--版权文件-->
|
||||
<fileSet>
|
||||
<directory>../../</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>LICENSE</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<!-- 依赖的 jar 包 copy 到 lib 目录下 -->
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<includes>
|
||||
<include>io.jpom:server</include>
|
||||
</includes>
|
||||
</dependencySet>
|
||||
<!-- <dependencySet>-->
|
||||
<!-- <outputDirectory>lib/plugins</outputDirectory>-->
|
||||
<!-- <includes>-->
|
||||
<!-- <include>io.jpom.plugins</include>-->
|
||||
<!-- </includes>-->
|
||||
<!-- </dependencySet>-->
|
||||
</dependencySets>
|
||||
|
||||
</assembly>
|
91
modules/server/src/main/assembly/release.xml
Normal file
91
modules/server/src/main/assembly/release.xml
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Code Technology Studio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
-->
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
||||
<id>release</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
<format>zip</format>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
|
||||
<fileSets>
|
||||
<!-- 打包Jpom 管理命令文件-->
|
||||
<fileSet>
|
||||
<directory>./src/main/bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>Server.sh</include>
|
||||
</includes>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
|
||||
<fileSet>
|
||||
<directory>./src/main/bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>Server.bat</include>
|
||||
</includes>
|
||||
<lineEnding>dos</lineEnding>
|
||||
</fileSet>
|
||||
<!--复制外部配置文件-->
|
||||
<fileSet>
|
||||
<directory>./src/main/resources/config_default/</directory>
|
||||
<outputDirectory>/conf</outputDirectory>
|
||||
<includes>
|
||||
<include>logback.xml</include>
|
||||
<include>application.yml</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<!--版权文件-->
|
||||
<fileSet>
|
||||
<directory>../../</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>LICENSE</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
<!-- 依赖的 jar 包 copy 到 lib 目录下 -->
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<includes>
|
||||
<include>io.jpom:server</include>
|
||||
</includes>
|
||||
</dependencySet>
|
||||
<!-- <dependencySet>-->
|
||||
<!-- <outputDirectory>lib/plugins</outputDirectory>-->
|
||||
<!-- <includes>-->
|
||||
<!-- <include>io.jpom.plugins</include>-->
|
||||
<!-- </includes>-->
|
||||
<!-- </dependencySet>-->
|
||||
</dependencySets>
|
||||
|
||||
</assembly>
|
@ -25,32 +25,22 @@ package io.jpom;
|
||||
import cn.hutool.core.date.BetweenFormatter;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.SystemClock;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.jiangzeyin.common.EnableCommonBoot;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import cn.jiangzeyin.common.spring.event.ApplicationEventLoad;
|
||||
import io.jpom.common.JpomAppType;
|
||||
import io.jpom.common.Type;
|
||||
import io.jpom.common.interceptor.IpInterceptor;
|
||||
import io.jpom.common.interceptor.LoginInterceptor;
|
||||
import io.jpom.common.interceptor.OpenApiInterceptor;
|
||||
import io.jpom.common.interceptor.PermissionInterceptor;
|
||||
import io.jpom.model.data.BackupInfoModel;
|
||||
import io.jpom.model.data.SystemIpConfigModel;
|
||||
import io.jpom.service.dblog.BackupInfoService;
|
||||
import io.jpom.service.system.SystemParametersServer;
|
||||
import io.jpom.service.user.UserService;
|
||||
import io.jpom.system.db.DbConfig;
|
||||
import io.jpom.system.init.InitDb;
|
||||
import io.jpom.util.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* jpom 启动类
|
||||
*
|
||||
@ -60,12 +50,9 @@ import java.util.concurrent.Future;
|
||||
@SpringBootApplication
|
||||
@ServletComponentScan
|
||||
@EnableCommonBoot
|
||||
public class JpomServerApplication implements ApplicationEventLoad {
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private static String[] ARGS;
|
||||
@Slf4j
|
||||
@JpomAppType(Type.Server)
|
||||
public class JpomServerApplication {
|
||||
|
||||
/**
|
||||
* 启动执行
|
||||
@ -93,9 +80,8 @@ public class JpomServerApplication implements ApplicationEventLoad {
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
long time = SystemClock.now();
|
||||
ARGS = args;
|
||||
//
|
||||
JpomApplication jpomApplication = new JpomApplication(Type.Server, JpomServerApplication.class, args);
|
||||
JpomApplication jpomApplication = new JpomApplication(JpomServerApplication.class);
|
||||
jpomApplication
|
||||
// 拦截器
|
||||
.addInterceptor(IpInterceptor.class)
|
||||
@ -107,16 +93,16 @@ public class JpomServerApplication implements ApplicationEventLoad {
|
||||
if (ArrayUtil.containsIgnoreCase(args, "--rest:ip_config")) {
|
||||
SystemParametersServer parametersServer = SpringUtil.getBean(SystemParametersServer.class);
|
||||
parametersServer.delByKey(SystemIpConfigModel.ID);
|
||||
Console.log("Clear IP whitelist configuration successfully");
|
||||
log.info("Clear IP whitelist configuration successfully");
|
||||
}
|
||||
// 重置超级管理员密码
|
||||
if (ArrayUtil.containsIgnoreCase(args, "--rest:super_user_pwd")) {
|
||||
UserService userService = SpringUtil.getBean(UserService.class);
|
||||
String restResult = userService.restSuperUserPwd();
|
||||
if (restResult != null) {
|
||||
Console.log(restResult);
|
||||
log.info(restResult);
|
||||
} else {
|
||||
Console.log("There is no super administrator account in the system");
|
||||
log.error("There is no super administrator account in the system");
|
||||
}
|
||||
}
|
||||
// 关闭超级管理员 mfa
|
||||
@ -124,91 +110,13 @@ public class JpomServerApplication implements ApplicationEventLoad {
|
||||
UserService userService = SpringUtil.getBean(UserService.class);
|
||||
String restResult = userService.closeSuperUserMfa();
|
||||
if (restResult != null) {
|
||||
Console.log(restResult);
|
||||
log.info(restResult);
|
||||
} else {
|
||||
Console.log("There is no super administrator account in the system");
|
||||
log.error("There is no super administrator account in the system");
|
||||
}
|
||||
}
|
||||
Console.log("Time-consuming to start this time:{}", DateUtil.formatBetween(SystemClock.now() - time, BetweenFormatter.Level.MILLISECOND));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applicationLoad() {
|
||||
DbConfig instance = DbConfig.getInstance();
|
||||
if (ArrayUtil.containsIgnoreCase(ARGS, "--rest:load_init_db")) {
|
||||
// 重新执行数据库初始化操作,一般用于手动修改数据库字段错误后,恢复默认的字段
|
||||
instance.clearExecuteSqlLog();
|
||||
}
|
||||
if (ArrayUtil.containsIgnoreCase(ARGS, "--recover:h2db")) {
|
||||
// 恢复数据库,一般用于非正常关闭程序导致数据库奔溃,执行恢复数据逻辑
|
||||
try {
|
||||
instance.recoverDb();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JpomApplication.consoleExit(-2, "Failed to restore database:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
if (ArrayUtil.containsIgnoreCase(ARGS, "--backup-h2")) {
|
||||
// 备份数据库
|
||||
InitDb.addCallback(() -> {
|
||||
Console.log("Start backing up the database");
|
||||
BackupInfoService backupInfoService = SpringUtil.getBean(BackupInfoService.class);
|
||||
Future<BackupInfoModel> backupInfoModelFuture = backupInfoService.autoBackup();
|
||||
try {
|
||||
BackupInfoModel backupInfoModel = backupInfoModelFuture.get();
|
||||
JpomApplication.consoleExit(0, "Complete the backup database, save the path as {}", backupInfoModel.getFilePath());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JpomApplication.consoleExit(-2, "Backup database failed:{}", e.getMessage());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
String importH2Sql = StringUtil.getArgsValue(ARGS, "import-h2-sql");
|
||||
if (StrUtil.isNotEmpty(importH2Sql)) {
|
||||
// 导入数据
|
||||
importH2Sql(importH2Sql);
|
||||
}
|
||||
String replaceImportH2Sql = StringUtil.getArgsValue(ARGS, "replace-import-h2-sql");
|
||||
if (StrUtil.isNotEmpty(replaceImportH2Sql)) {
|
||||
// 删除掉旧数据
|
||||
InitDb.addBeforeCallback(() -> {
|
||||
try {
|
||||
String dbFiles = instance.deleteDbFiles();
|
||||
if (dbFiles != null) {
|
||||
Console.log("Automatically backup data files to {} path", dbFiles);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JpomApplication.consoleExit(-2, "Failed to import according to sql,{}", replaceImportH2Sql);
|
||||
}
|
||||
});
|
||||
// 导入数据
|
||||
importH2Sql(replaceImportH2Sql);
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
private static void importH2Sql(String importH2Sql) {
|
||||
InitDb.addCallback(() -> {
|
||||
File file = FileUtil.file(importH2Sql);
|
||||
String sqlPath = FileUtil.getAbsolutePath(file);
|
||||
if (!FileUtil.isFile(file)) {
|
||||
JpomApplication.consoleExit(2, "sql file does not exist :{}", sqlPath);
|
||||
}
|
||||
//
|
||||
if (ArrayUtil.containsIgnoreCase(ARGS, "--transform-sql")) {
|
||||
DbConfig.getInstance().transformSql(file);
|
||||
}
|
||||
//
|
||||
Console.log("Start importing data:{}", sqlPath);
|
||||
BackupInfoService backupInfoService = SpringUtil.getBean(BackupInfoService.class);
|
||||
boolean flag = backupInfoService.restoreWithSql(sqlPath);
|
||||
if (!flag) {
|
||||
JpomApplication.consoleExit(2, "Failed to import according to sql,{}", sqlPath);
|
||||
}
|
||||
Console.log("Import successfully according to sql,{}", sqlPath);
|
||||
return true;
|
||||
});
|
||||
log.info("Time-consuming to start this time:{}", DateUtil.formatBetween(SystemClock.now() - time, BetweenFormatter.Level.MILLISECOND));
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.BaseEnum;
|
||||
import io.jpom.model.data.BuildInfoModel;
|
||||
import io.jpom.model.data.RepositoryModel;
|
||||
|
@ -29,7 +29,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.SystemClock;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.LineHandler;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.text.CharPool;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
@ -38,11 +37,11 @@ import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.extra.ssh.JschUtil;
|
||||
import cn.hutool.extra.ssh.Sftp;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jcraft.jsch.Session;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.forward.NodeForward;
|
||||
import io.jpom.common.forward.NodeUrl;
|
||||
import io.jpom.model.AfterOpt;
|
||||
@ -72,7 +71,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -379,7 +377,7 @@ public class ReleaseManage implements Runnable {
|
||||
logRecorder.info(DateUtil.now() + " start exec");
|
||||
InputStream templateInputStream = null;
|
||||
try {
|
||||
templateInputStream = ResourceUtil.getStream("classpath:/bin/execTemplate." + CommandUtil.SUFFIX);
|
||||
templateInputStream = ResourceUtil.getStream("classpath:/config_default/execTemplate." + CommandUtil.SUFFIX);
|
||||
if (templateInputStream == null) {
|
||||
logRecorder.info("系统中没有命令模版");
|
||||
return;
|
||||
|
@ -26,8 +26,10 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import io.jpom.system.*;
|
||||
import io.jpom.system.AgentException;
|
||||
import io.jpom.system.AuthorizeException;
|
||||
import io.jpom.system.JpomRuntimeException;
|
||||
import io.jpom.system.ServerConfigBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
@ -102,10 +104,8 @@ public class GlobalDefaultExceptionHandler extends BaseExceptionHandler {
|
||||
*/
|
||||
@ExceptionHandler({IllegalArgumentException.class, IllegalStateException.class, ValidateException.class})
|
||||
public void paramExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception e) {
|
||||
if (!ConfigBean.getInstance().isPro()) {
|
||||
// 只是本地调试才输出日志
|
||||
log.error("controller " + request.getRequestURI(), e);
|
||||
}
|
||||
// 默认不输出 参数异常相关信息
|
||||
log.debug("controller " + request.getRequestURI(), e);
|
||||
String message = e.getMessage();
|
||||
if (ObjectUtil.equals(message, ServerConfigBean.AUTHORIZE_TIME_OUT_CODE)) {
|
||||
ServletUtil.write(response, JsonMessage.getString(ServerConfigBean.AUTHORIZE_TIME_OUT_CODE, ServerConfigBean.LOGIN_TIP), MediaType.APPLICATION_JSON_VALUE);
|
||||
|
@ -30,13 +30,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.http.*;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.Const;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.data.NodeModel;
|
||||
import io.jpom.model.user.UserModel;
|
||||
import io.jpom.service.node.NodeService;
|
||||
@ -400,7 +399,7 @@ public class NodeForward {
|
||||
// httpRequest.header(ConfigBean.JPOM_SERVER_SYSTEM_USER_ROLE, userModel.getUserRole(nodeModel).name());
|
||||
}
|
||||
if (StrUtil.isEmpty(nodeModel.getLoginPwd())) {
|
||||
NodeService nodeService = SpringUtil.getBean(NodeService.class);
|
||||
NodeService nodeService = cn.hutool.extra.spring.SpringUtil.getBean(NodeService.class);
|
||||
NodeModel model = nodeService.getByKey(nodeModel.getId(), false);
|
||||
nodeModel.setLoginPwd(model.getLoginPwd());
|
||||
nodeModel.setLoginName(model.getLoginName());
|
||||
@ -445,7 +444,7 @@ public class NodeForward {
|
||||
ws = "ws";
|
||||
}
|
||||
if (StrUtil.isEmpty(nodeModel.getLoginPwd())) {
|
||||
NodeService nodeService = SpringUtil.getBean(NodeService.class);
|
||||
NodeService nodeService = cn.hutool.extra.spring.SpringUtil.getBean(NodeService.class);
|
||||
NodeModel model = nodeService.getByKey(nodeModel.getId(), false);
|
||||
nodeModel.setLoginPwd(model.getLoginPwd());
|
||||
nodeModel.setLoginName(model.getLoginName());
|
||||
|
@ -22,8 +22,6 @@
|
||||
*/
|
||||
package io.jpom.common.forward;
|
||||
|
||||
import io.jpom.system.ServerExtConfigBean;
|
||||
|
||||
/**
|
||||
* agent 端的请求地址枚举
|
||||
*
|
||||
@ -106,7 +104,7 @@ public enum NodeUrl {
|
||||
/**
|
||||
* jzy add timeout
|
||||
*/
|
||||
Manage_File_Upload("/manage/file/upload", ServerExtConfigBean.getInstance().getUploadFileTimeOut()),
|
||||
Manage_File_Upload("/manage/file/upload"),
|
||||
|
||||
Manage_File_DeleteFile("/manage/file/deleteFile"),
|
||||
/**
|
||||
@ -146,12 +144,12 @@ public enum NodeUrl {
|
||||
Manage_internal_ram("/manage/internal_ram"),
|
||||
Manage_internal_threadInfos("/manage/threadInfos"),
|
||||
|
||||
/**
|
||||
* jdk
|
||||
*/
|
||||
Manage_jdk_list("/manage/jdk/list"),
|
||||
Manage_jdk_update("/manage/jdk/update"),
|
||||
Manage_jdk_delete("/manage/jdk/delete"),
|
||||
// /**
|
||||
// * jdk
|
||||
// */
|
||||
// Manage_jdk_list("/manage/jdk/list"),
|
||||
// Manage_jdk_update("/manage/jdk/update"),
|
||||
// Manage_jdk_delete("/manage/jdk/delete"),
|
||||
|
||||
System_Nginx_list_data("/system/nginx/list_data.json"),
|
||||
System_Nginx_Tree("/system/nginx/tree.json"),
|
||||
@ -185,23 +183,23 @@ public enum NodeUrl {
|
||||
Script_Upload("/script/upload.json"),
|
||||
Script_Del("/script/del.json"),
|
||||
|
||||
Tomcat_List("/tomcat/list"),
|
||||
Tomcat_Add("/tomcat/add"),
|
||||
Tomcat_Update("/tomcat/update"),
|
||||
Tomcat_Delete("/tomcat/delete"),
|
||||
Tomcat_Start("/tomcat/start"),
|
||||
Tomcat_Stop("/tomcat/stop"),
|
||||
Tomcat_Restart("/tomcat/restart"),
|
||||
Tomcat_GetItem("/tomcat/getItem"),
|
||||
Tomcat_LOG_List("/tomcat/logList"),
|
||||
Tomcat_GetTomcatProjectList("/tomcat/getTomcatProjectList"),
|
||||
Tomcat_GetTomcatStatus("/tomcat/getTomcatStatus"),
|
||||
Tomcat_TomcatProjectManage("/tomcat/tomcatProjectManage"),
|
||||
Tomcat_File_GetFileList("/tomcat/getFileList"),
|
||||
Tomcat_File_DeleteFile("/tomcat/deleteFile"),
|
||||
Tomcat_File_Download("/tomcat/download"),
|
||||
Tomcat_File_Upload("/tomcat/upload"),
|
||||
Tomcat_File_UploadWar("/tomcat/uploadWar"),
|
||||
// Tomcat_List("/tomcat/list"),
|
||||
// Tomcat_Add("/tomcat/add"),
|
||||
// Tomcat_Update("/tomcat/update"),
|
||||
// Tomcat_Delete("/tomcat/delete"),
|
||||
// Tomcat_Start("/tomcat/start"),
|
||||
// Tomcat_Stop("/tomcat/stop"),
|
||||
// Tomcat_Restart("/tomcat/restart"),
|
||||
// Tomcat_GetItem("/tomcat/getItem"),
|
||||
// Tomcat_LOG_List("/tomcat/logList"),
|
||||
// Tomcat_GetTomcatProjectList("/tomcat/getTomcatProjectList"),
|
||||
// Tomcat_GetTomcatStatus("/tomcat/getTomcatStatus"),
|
||||
// Tomcat_TomcatProjectManage("/tomcat/tomcatProjectManage"),
|
||||
// Tomcat_File_GetFileList("/tomcat/getFileList"),
|
||||
// Tomcat_File_DeleteFile("/tomcat/deleteFile"),
|
||||
// Tomcat_File_Download("/tomcat/download"),
|
||||
// Tomcat_File_Upload("/tomcat/upload"),
|
||||
// Tomcat_File_UploadWar("/tomcat/uploadWar"),
|
||||
|
||||
/**
|
||||
* Workspace
|
||||
|
@ -26,9 +26,9 @@ import cn.hutool.core.net.Ipv4Util;
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.interceptor.InterceptorPattens;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.ServerOpenApi;
|
||||
import io.jpom.model.data.SystemIpConfigModel;
|
||||
import io.jpom.service.system.SystemParametersServer;
|
||||
|
@ -25,10 +25,10 @@ package io.jpom.common.interceptor;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.jwt.JWT;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.interceptor.InterceptorPattens;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.ServerOpenApi;
|
||||
import io.jpom.model.user.UserModel;
|
||||
import io.jpom.service.user.UserService;
|
||||
@ -71,7 +71,8 @@ public class LoginInterceptor extends BaseJpomInterceptor {
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod) throws Exception {
|
||||
HttpSession session = getSession();
|
||||
boolean init = DbConfig.getInstance().isInit();
|
||||
DbConfig dbConfig = SpringUtil.getBean(DbConfig.class);
|
||||
boolean init = dbConfig.isInit();
|
||||
if (!init) {
|
||||
ServletUtil.write(response, JsonMessage.getString(100, "数据库还没有初始化成功,请耐心等待"), MediaType.APPLICATION_JSON_VALUE);
|
||||
return false;
|
||||
|
@ -25,9 +25,9 @@ package io.jpom.common.interceptor;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.interceptor.BaseInterceptor;
|
||||
import cn.jiangzeyin.common.interceptor.InterceptorPattens;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.ServerOpenApi;
|
||||
import io.jpom.system.ServerExtConfigBean;
|
||||
import org.springframework.http.MediaType;
|
||||
|
@ -25,10 +25,10 @@ package io.jpom.common.interceptor;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.interceptor.InterceptorPattens;
|
||||
import cn.jiangzeyin.common.spring.SpringUtil;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.BaseNodeModel;
|
||||
import io.jpom.model.data.NodeModel;
|
||||
import io.jpom.model.user.UserBindWorkspaceModel;
|
||||
|
@ -35,10 +35,10 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.http.ContentType;
|
||||
import cn.hutool.system.SystemUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.UrlRedirectUtil;
|
||||
import io.jpom.common.interceptor.BaseJpomInterceptor;
|
||||
import io.jpom.common.interceptor.NotLogin;
|
||||
@ -48,7 +48,6 @@ import io.jpom.service.h2db.BaseWorkspaceService;
|
||||
import io.jpom.service.system.SystemParametersServer;
|
||||
import io.jpom.service.user.UserBindWorkspaceService;
|
||||
import io.jpom.service.user.UserService;
|
||||
import io.jpom.system.ConfigBean;
|
||||
import io.jpom.system.ExtConfigBean;
|
||||
import io.jpom.system.ServerExtConfigBean;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -304,13 +303,13 @@ public class IndexControl extends BaseServerController {
|
||||
}
|
||||
|
||||
private boolean testMenus(JSONObject jsonObject, UserModel userModel, NodeModel nodeModel, JSONArray showArray) {
|
||||
String active = jsonObject.getString("active");
|
||||
if (StrUtil.isNotEmpty(active)) {
|
||||
String active1 = ConfigBean.getInstance().getActive();
|
||||
if (!StrUtil.equals(active, active1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// String active = jsonObject.getString("active");
|
||||
// if (StrUtil.isNotEmpty(active)) {
|
||||
// String active1 = ConfigBean.getInstance().getActive();
|
||||
// if (!StrUtil.equals(active, active1)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
String role = jsonObject.getString("role");
|
||||
if (StrUtil.equals(role, UserModel.SYSTEM_ADMIN) && !userModel.isSuperSystemUser()) {
|
||||
// 超级理员权限
|
||||
|
@ -24,7 +24,6 @@ package io.jpom.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorConfig;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
@ -32,6 +31,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.JpomApplication;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.Const;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.interceptor.LoginInterceptor;
|
||||
import io.jpom.common.interceptor.NotLogin;
|
||||
import io.jpom.model.data.WorkspaceModel;
|
||||
|
@ -33,12 +33,12 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.jwt.JWT;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorConfig;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.common.ServerOpenApi;
|
||||
import io.jpom.common.interceptor.LoginInterceptor;
|
||||
import io.jpom.common.interceptor.NotLogin;
|
||||
|
@ -29,7 +29,6 @@ import cn.hutool.core.lang.Tuple;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorConfig;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
@ -39,6 +38,7 @@ import io.jpom.build.BuildExecuteService;
|
||||
import io.jpom.build.BuildUtil;
|
||||
import io.jpom.build.DockerYmlDsl;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.AfterOpt;
|
||||
import io.jpom.model.BaseEnum;
|
||||
import io.jpom.model.PageResultDto;
|
||||
|
@ -26,12 +26,12 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.jiangzeyin.common.JsonMessage;
|
||||
import cn.jiangzeyin.common.validator.ValidatorConfig;
|
||||
import cn.jiangzeyin.common.validator.ValidatorItem;
|
||||
import cn.jiangzeyin.common.validator.ValidatorRule;
|
||||
import io.jpom.build.BuildUtil;
|
||||
import io.jpom.common.BaseServerController;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.model.PageResultDto;
|
||||
import io.jpom.model.data.BuildInfoModel;
|
||||
import io.jpom.model.log.BuildHistoryLog;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user