mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 03:48:05 +08:00
代码调整,文档更新
This commit is contained in:
parent
7817e1cb60
commit
0fdea6d271
14
PLANS.md
14
PLANS.md
@ -1,7 +1,9 @@
|
|||||||
### 开发计划
|
### 开发计划
|
||||||
|
|
||||||
1. 兼容windows 服务器
|
1. 主要管理页面兼容移动端
|
||||||
2. 主要管理页面兼容移动端
|
2. nginx 快捷管理
|
||||||
3. 账号暴露破解
|
3. ssl 到期提醒、快捷续签
|
||||||
4. nginx 快捷管理
|
|
||||||
5. ssl 到期提醒、快捷续签
|
~~1. 兼容windows 服务器~~
|
||||||
|
|
||||||
|
~~2. 账号暴露破解~~
|
10
README.md
10
README.md
@ -103,8 +103,10 @@ mvn package
|
|||||||
|
|
||||||
[http://jpom-demo.jiangzeyin.cn](http://jpom-demo.jiangzeyin.cn)
|
[http://jpom-demo.jiangzeyin.cn](http://jpom-demo.jiangzeyin.cn)
|
||||||
|
|
||||||
账号:admin
|
账号:demo
|
||||||
密码:admin123
|
密码:demo123
|
||||||
|
|
||||||
|
> 演示系统有部分功能做了限制,详情功能请自行部署体验
|
||||||
|
|
||||||
1. [Jboot案例代码](https://gitee.com/keepbx/Jpom-demo-case/tree/master/jboot-test)
|
1. [Jboot案例代码](https://gitee.com/keepbx/Jpom-demo-case/tree/master/jboot-test)
|
||||||
2. [SpringBoot案例代码](https://gitee.com/keepbx/Jpom-demo-case/tree/master/springboot-test)
|
2. [SpringBoot案例代码](https://gitee.com/keepbx/Jpom-demo-case/tree/master/springboot-test)
|
||||||
@ -123,10 +125,6 @@ mvn package
|
|||||||
|
|
||||||
[用户角色说明>>](/doc/safeMode.md#用户权限说明)
|
[用户角色说明>>](/doc/safeMode.md#用户权限说明)
|
||||||
|
|
||||||
### windows 开启实时查看控制台日志
|
|
||||||
|
|
||||||
[飞机>>](/doc/windows-tail.md)
|
|
||||||
|
|
||||||
### 阿里云Oss配置
|
### 阿里云Oss配置
|
||||||
|
|
||||||
[查看文档](/doc/CodePipeline-Oss.md)
|
[查看文档](/doc/CodePipeline-Oss.md)
|
||||||
|
@ -39,7 +39,7 @@ public abstract class BaseDataService {
|
|||||||
JSONObject data = allData.getJSONObject(key);
|
JSONObject data = allData.getJSONObject(key);
|
||||||
// 判断是否存在数据
|
// 判断是否存在数据
|
||||||
if (null != data && 0 < data.keySet().size()) {
|
if (null != data && 0 < data.keySet().size()) {
|
||||||
throw new RuntimeException("项目名称已存在!");
|
throw new RuntimeException("数据Id已经存在啦:" + filename + " :" + key);
|
||||||
} else {
|
} else {
|
||||||
allData.put(key, json);
|
allData.put(key, json);
|
||||||
JsonUtil.saveJson(getDataFilePath(filename), allData);
|
JsonUtil.saveJson(getDataFilePath(filename), allData);
|
||||||
@ -60,7 +60,7 @@ public abstract class BaseDataService {
|
|||||||
|
|
||||||
// 判断是否存在数据
|
// 判断是否存在数据
|
||||||
if (null == data || 0 == data.keySet().size()) {
|
if (null == data || 0 == data.keySet().size()) {
|
||||||
throw new Exception("数据不存在");
|
throw new Exception("数据不存在:" + key);
|
||||||
} else {
|
} else {
|
||||||
allData.put(key, json);
|
allData.put(key, json);
|
||||||
JsonUtil.saveJson(getDataFilePath(filename), allData);
|
JsonUtil.saveJson(getDataFilePath(filename), allData);
|
||||||
@ -98,5 +98,15 @@ public abstract class BaseDataService {
|
|||||||
return (JSONObject) JsonUtil.readJson(getDataFilePath(filename));
|
return (JSONObject) JsonUtil.readJson(getDataFilePath(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected <T> T getJsonObjectById(String file, String id, Class<T> cls) throws IOException {
|
||||||
|
JSONObject jsonObject = getJsonObject(file);
|
||||||
|
if (jsonObject == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
jsonObject = jsonObject.getJSONObject(id);
|
||||||
|
if (jsonObject == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return jsonObject.toJavaObject(cls);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,9 +169,9 @@ public abstract class AbstractCommander {
|
|||||||
// 通过VirtualMachine.list()列出所有的java进程
|
// 通过VirtualMachine.list()列出所有的java进程
|
||||||
List<VirtualMachineDescriptor> descriptorList = VirtualMachine.list();
|
List<VirtualMachineDescriptor> descriptorList = VirtualMachine.list();
|
||||||
for (VirtualMachineDescriptor virtualMachineDescriptor : descriptorList) {
|
for (VirtualMachineDescriptor virtualMachineDescriptor : descriptorList) {
|
||||||
VirtualMachine virtualMachine = VirtualMachine.attach(virtualMachineDescriptor);
|
|
||||||
int pid = Convert.toInt(virtualMachineDescriptor.id(), 0);
|
int pid = Convert.toInt(virtualMachineDescriptor.id(), 0);
|
||||||
// 根据进程id查询启动属性,如果属性-Dapplication匹配,说明项目已经启动,并返回进程id
|
// 根据进程id查询启动属性,如果属性-Dapplication匹配,说明项目已经启动,并返回进程id
|
||||||
|
VirtualMachine virtualMachine = VirtualMachine.attach(virtualMachineDescriptor);
|
||||||
Properties properties = virtualMachine.getAgentProperties();
|
Properties properties = virtualMachine.getAgentProperties();
|
||||||
String args = StrUtil.emptyToDefault(properties.getProperty("sun.jvm.args"), "");
|
String args = StrUtil.emptyToDefault(properties.getProperty("sun.jvm.args"), "");
|
||||||
if (StrUtil.containsIgnoreCase(args, tag)) {
|
if (StrUtil.containsIgnoreCase(args, tag)) {
|
||||||
@ -187,7 +187,7 @@ public abstract class AbstractCommander {
|
|||||||
if (jmxServiceURL != null) {
|
if (jmxServiceURL != null) {
|
||||||
JMXConnector jmxc = JMXConnectorFactory.connect(jmxServiceURL, null);
|
JMXConnector jmxc = JMXConnectorFactory.connect(jmxServiceURL, null);
|
||||||
MBeanServerConnection mBeanServerConnection = jmxc.getMBeanServerConnection();
|
MBeanServerConnection mBeanServerConnection = jmxc.getMBeanServerConnection();
|
||||||
|
|
||||||
MemoryMXBean memBean = ManagementFactory.newPlatformMXBeanProxy
|
MemoryMXBean memBean = ManagementFactory.newPlatformMXBeanProxy
|
||||||
(mBeanServerConnection, ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class);
|
(mBeanServerConnection, ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class LoginControl extends BaseController {
|
|||||||
@RequestMapping(value = "userLogin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping(value = "userLogin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@NotLogin
|
@NotLogin
|
||||||
public String userLogin(String userName, String userPwd, String code) {
|
public String userLogin(String userName, String userPwd, String code) throws IOException {
|
||||||
if (StrUtil.isEmpty(userName) || StrUtil.isEmpty(userPwd)) {
|
if (StrUtil.isEmpty(userName) || StrUtil.isEmpty(userPwd)) {
|
||||||
return JsonMessage.getString(405, "请输入登录信息");
|
return JsonMessage.getString(405, "请输入登录信息");
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package cn.keepbx.jpom.controller.manage;
|
package cn.keepbx.jpom.controller.manage;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||||
import cn.jiangzeyin.common.JsonMessage;
|
import cn.jiangzeyin.common.JsonMessage;
|
||||||
import cn.keepbx.jpom.common.BaseController;
|
import cn.keepbx.jpom.common.BaseController;
|
||||||
import cn.keepbx.jpom.model.ProjectInfoModel;
|
import cn.keepbx.jpom.model.ProjectInfoModel;
|
||||||
import cn.keepbx.jpom.model.UserModel;
|
import cn.keepbx.jpom.model.UserModel;
|
||||||
import cn.keepbx.jpom.service.manage.CommandService;
|
|
||||||
import cn.keepbx.jpom.service.manage.ProjectInfoService;
|
import cn.keepbx.jpom.service.manage.ProjectInfoService;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
@ -35,8 +33,6 @@ public class ConsoleController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProjectInfoService projectInfoService;
|
private ProjectInfoService projectInfoService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CommandService commandService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理项目
|
* 管理项目
|
||||||
@ -44,7 +40,7 @@ public class ConsoleController extends BaseController {
|
|||||||
* @return page
|
* @return page
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "console", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
@RequestMapping(value = "console", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
||||||
public String console(String id) throws IOException {
|
public String console(String id) {
|
||||||
ProjectInfoModel projectInfoModel = null;
|
ProjectInfoModel projectInfoModel = null;
|
||||||
try {
|
try {
|
||||||
projectInfoModel = projectInfoService.getItem(id);
|
projectInfoModel = projectInfoService.getItem(id);
|
||||||
@ -55,7 +51,7 @@ public class ConsoleController extends BaseController {
|
|||||||
UserModel userName = getUser();
|
UserModel userName = getUser();
|
||||||
setAttribute("projectInfo", projectInfoModel);
|
setAttribute("projectInfo", projectInfoModel);
|
||||||
setAttribute("userInfo", userName.getUserMd5Key());
|
setAttribute("userInfo", userName.getUserMd5Key());
|
||||||
String logSize = getLogSize(id);
|
String logSize = projectInfoService.getLogSize(id);
|
||||||
setAttribute("logSize", logSize);
|
setAttribute("logSize", logSize);
|
||||||
setAttribute("manager", userName.isProject(id));
|
setAttribute("manager", userName.isProject(id));
|
||||||
|
|
||||||
@ -68,53 +64,6 @@ public class ConsoleController extends BaseController {
|
|||||||
return "manage/console";
|
return "manage/console";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "logSize", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
public String logSize(String id) throws IOException {
|
|
||||||
String info = getLogSize(id);
|
|
||||||
if (info != null) {
|
|
||||||
return JsonMessage.getString(200, "ok", info);
|
|
||||||
}
|
|
||||||
return JsonMessage.getString(500, "获取日志大小失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "resetLog", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
||||||
@ResponseBody
|
|
||||||
public String resetLog(String id) {
|
|
||||||
ProjectInfoModel pim;
|
|
||||||
try {
|
|
||||||
pim = projectInfoService.getItem(id);
|
|
||||||
String msg = commandService.execCommand(CommandService.CommandOp.backupLog, pim);
|
|
||||||
if (msg.contains("ok")) {
|
|
||||||
return JsonMessage.getString(200, "重置成功");
|
|
||||||
}
|
|
||||||
return JsonMessage.getString(201, "重置失败:" + msg);
|
|
||||||
} catch (Exception e) {
|
|
||||||
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
|
||||||
return JsonMessage.getString(500, "重置日志失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getLogSize(String id) {
|
|
||||||
ProjectInfoModel pim;
|
|
||||||
try {
|
|
||||||
pim = projectInfoService.getItem(id);
|
|
||||||
if (pim == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String logSize = null;
|
|
||||||
File file = new File(pim.getLog());
|
|
||||||
if (file.exists()) {
|
|
||||||
long fileSize = file.length();
|
|
||||||
logSize = FileUtil.readableFileSize(fileSize);
|
|
||||||
}
|
|
||||||
return logSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "export.html", method = RequestMethod.GET)
|
@RequestMapping(value = "export.html", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -8,6 +8,7 @@ import cn.jiangzeyin.common.JsonMessage;
|
|||||||
import cn.keepbx.jpom.common.BaseController;
|
import cn.keepbx.jpom.common.BaseController;
|
||||||
import cn.keepbx.jpom.common.interceptor.ProjectPermission;
|
import cn.keepbx.jpom.common.interceptor.ProjectPermission;
|
||||||
import cn.keepbx.jpom.model.ProjectInfoModel;
|
import cn.keepbx.jpom.model.ProjectInfoModel;
|
||||||
|
import cn.keepbx.jpom.service.manage.CommandService;
|
||||||
import cn.keepbx.jpom.service.manage.ProjectInfoService;
|
import cn.keepbx.jpom.service.manage.ProjectInfoService;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@ -32,6 +33,9 @@ public class LogBackController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProjectInfoService projectInfoService;
|
private ProjectInfoService projectInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CommandService commandService;
|
||||||
|
|
||||||
@RequestMapping(value = "logBack", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
@RequestMapping(value = "logBack", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
|
||||||
public String console(String id) {
|
public String console(String id) {
|
||||||
try {
|
try {
|
||||||
@ -96,4 +100,34 @@ public class LogBackController extends BaseController {
|
|||||||
return JsonMessage.getString(500, "没有对应文件夹");
|
return JsonMessage.getString(500, "没有对应文件夹");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "logSize", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
|
@ResponseBody
|
||||||
|
public String logSize(String id) {
|
||||||
|
String info = projectInfoService.getLogSize(id);
|
||||||
|
if (info != null) {
|
||||||
|
return JsonMessage.getString(200, "ok", info);
|
||||||
|
}
|
||||||
|
return JsonMessage.getString(500, "获取日志大小失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "resetLog", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
|
@ResponseBody
|
||||||
|
public String resetLog(String id) {
|
||||||
|
ProjectInfoModel pim;
|
||||||
|
try {
|
||||||
|
pim = projectInfoService.getItem(id);
|
||||||
|
String msg = commandService.execCommand(CommandService.CommandOp.backupLog, pim);
|
||||||
|
if (msg.contains("ok")) {
|
||||||
|
return JsonMessage.getString(200, "重置成功");
|
||||||
|
}
|
||||||
|
return JsonMessage.getString(201, "重置失败:" + msg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
||||||
|
return JsonMessage.getString(500, "重置日志失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户管理
|
* 用户管理
|
||||||
@ -73,7 +74,7 @@ public class UserInfoController extends BaseController {
|
|||||||
* @return json
|
* @return json
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "updateName", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping(value = "updateName", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public String updateName(String name) {
|
public String updateName(String name) throws IOException {
|
||||||
if (StrUtil.isEmpty(name)) {
|
if (StrUtil.isEmpty(name)) {
|
||||||
return JsonMessage.getString(405, "请输入新的昵称");
|
return JsonMessage.getString(405, "请输入新的昵称");
|
||||||
}
|
}
|
||||||
@ -98,7 +99,7 @@ public class UserInfoController extends BaseController {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "deleteUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping(value = "deleteUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public String deleteUser(String id) {
|
public String deleteUser(String id) throws IOException {
|
||||||
UserModel userName = getUser();
|
UserModel userName = getUser();
|
||||||
if (!userName.isManage()) {
|
if (!userName.isManage()) {
|
||||||
return JsonMessage.getString(400, "你没有删除用户的权限");
|
return JsonMessage.getString(400, "你没有删除用户的权限");
|
||||||
@ -130,7 +131,7 @@ public class UserInfoController extends BaseController {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "addUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping(value = "addUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public String addUser(String id) {
|
public String addUser(String id) throws IOException {
|
||||||
UserModel userName = getUser();
|
UserModel userName = getUser();
|
||||||
if (!userName.isManage()) {
|
if (!userName.isManage()) {
|
||||||
return JsonMessage.getString(400, "你还没有权限");
|
return JsonMessage.getString(400, "你还没有权限");
|
||||||
@ -204,9 +205,16 @@ public class UserInfoController extends BaseController {
|
|||||||
userModel.setManage(manageB);
|
userModel.setManage(manageB);
|
||||||
|
|
||||||
manageB = "true".equals(getParameter("uploadFile"));
|
manageB = "true".equals(getParameter("uploadFile"));
|
||||||
|
// 如果操作人没有权限 就不能管理被操作者
|
||||||
|
if (!userName.isUploadFile() && manageB) {
|
||||||
|
return JsonMessage.getString(402, "你没有管理上传文件的权限");
|
||||||
|
}
|
||||||
userModel.setUploadFile(manageB);
|
userModel.setUploadFile(manageB);
|
||||||
|
|
||||||
manageB = "true".equals(getParameter("deleteFile"));
|
manageB = "true".equals(getParameter("deleteFile"));
|
||||||
|
if (!userName.isDeleteFile() && manageB) {
|
||||||
|
return JsonMessage.getString(402, "你没有管理删除文件的权限");
|
||||||
|
}
|
||||||
userModel.setDeleteFile(manageB);
|
userModel.setDeleteFile(manageB);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -218,7 +226,7 @@ public class UserInfoController extends BaseController {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "updateUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@RequestMapping(value = "updateUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public String updateUser(String id) {
|
public String updateUser(String id) throws IOException {
|
||||||
UserModel userName = getUser();
|
UserModel userName = getUser();
|
||||||
if (!userName.isManage()) {
|
if (!userName.isManage()) {
|
||||||
return JsonMessage.getString(400, "你还没有权限");
|
return JsonMessage.getString(400, "你还没有权限");
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.keepbx.jpom.service.manage;
|
package cn.keepbx.jpom.service.manage;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||||
import cn.keepbx.jpom.common.BaseOperService;
|
import cn.keepbx.jpom.common.BaseOperService;
|
||||||
import cn.keepbx.jpom.model.ProjectInfoModel;
|
import cn.keepbx.jpom.model.ProjectInfoModel;
|
||||||
import cn.keepbx.jpom.system.ConfigBean;
|
import cn.keepbx.jpom.system.ConfigBean;
|
||||||
@ -7,6 +9,7 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -73,15 +76,26 @@ public class ProjectInfoService extends BaseOperService<ProjectInfoModel> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ProjectInfoModel getItem(String id) throws IOException {
|
public ProjectInfoModel getItem(String id) throws IOException {
|
||||||
JSONObject jsonObject = getJsonObject(ConfigBean.PROJECT);
|
return getJsonObjectById(ConfigBean.PROJECT, id, ProjectInfoModel.class);
|
||||||
if (jsonObject == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
jsonObject = jsonObject.getJSONObject(id);
|
|
||||||
if (jsonObject == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return jsonObject.toJavaObject(ProjectInfoModel.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLogSize(String id) {
|
||||||
|
ProjectInfoModel pim;
|
||||||
|
try {
|
||||||
|
pim = getItem(id);
|
||||||
|
if (pim == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String logSize = null;
|
||||||
|
File file = new File(pim.getLog());
|
||||||
|
if (file.exists()) {
|
||||||
|
long fileSize = file.length();
|
||||||
|
logSize = FileUtil.readableFileSize(fileSize);
|
||||||
|
}
|
||||||
|
return logSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,15 +70,7 @@ public class CertService extends BaseOperService<CertModel> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CertModel getItem(String id) throws IOException {
|
public CertModel getItem(String id) throws IOException {
|
||||||
JSONObject jsonObject = getJsonObject(ConfigBean.CERT);
|
return getJsonObjectById(ConfigBean.CERT, id, CertModel.class);
|
||||||
if (jsonObject == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
jsonObject = jsonObject.getJSONObject(id);
|
|
||||||
if (jsonObject == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return jsonObject.toJavaObject(CertModel.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,7 @@ public class UserService extends BaseOperService<UserModel> {
|
|||||||
* @param pwd 密码
|
* @param pwd 密码
|
||||||
* @return 登录
|
* @return 登录
|
||||||
*/
|
*/
|
||||||
public UserModel simpleLogin(String name, String pwd) {
|
public UserModel simpleLogin(String name, String pwd) throws IOException {
|
||||||
UserModel userModel = getItem(name);
|
UserModel userModel = getItem(name);
|
||||||
if (userModel == null) {
|
if (userModel == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -128,18 +128,8 @@ public class UserService extends BaseOperService<UserModel> {
|
|||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public UserModel getItem(String userId) {
|
public UserModel getItem(String userId) throws IOException {
|
||||||
try {
|
return getJsonObjectById(ConfigBean.USER, userId, UserModel.class);
|
||||||
JSONObject jsonObject = getJsonObject(ConfigBean.USER);
|
|
||||||
JSONObject user = jsonObject.getJSONObject(userId);
|
|
||||||
if (user == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return user.toJavaObject(UserModel.class);
|
|
||||||
} catch (IOException e) {
|
|
||||||
DefaultSystemLog.ERROR().error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ public class FileTailWatcher implements Runnable {
|
|||||||
try {
|
try {
|
||||||
return new FileTailWatcher(file, s);
|
return new FileTailWatcher(file, s);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
DefaultSystemLog.ERROR().error("创建文件监听失败", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -87,20 +87,31 @@ public class FileTailWatcher implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加监听回话
|
||||||
|
*
|
||||||
|
* @param session 回话
|
||||||
|
*/
|
||||||
private void add(Session session) {
|
private void add(Session session) {
|
||||||
if (this.socketSessions.add(session)) {
|
if (this.socketSessions.add(session)) {
|
||||||
try {
|
|
||||||
SocketSessionUtil.send(session, StrUtil.format("监听日志成功,目前共有{}人正在查看", this.socketSessions.size()));
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
if (this.limitQueue.size() <= 0) {
|
if (this.limitQueue.size() <= 0) {
|
||||||
send("日志文件为空");
|
this.send(session, "日志文件为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.send(session, StrUtil.format("监听日志成功,目前共有{}人正在查看", this.socketSessions.size()));
|
||||||
// 开发发送头信息
|
// 开发发送头信息
|
||||||
for (String s : this.limitQueue) {
|
for (String s : this.limitQueue) {
|
||||||
send(s);
|
this.send(session, s);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.send(session, "添加日志监听失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void send(Session session, String msg) {
|
||||||
|
try {
|
||||||
|
SocketSessionUtil.send(session, msg);
|
||||||
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,14 +137,14 @@ public class FileTailWatcher implements Runnable {
|
|||||||
tmp = CharsetUtil.convert(tmp, CharsetUtil.CHARSET_ISO_8859_1, CharsetUtil.systemCharset());
|
tmp = CharsetUtil.convert(tmp, CharsetUtil.CHARSET_ISO_8859_1, CharsetUtil.systemCharset());
|
||||||
limitQueue.offer(tmp);
|
limitQueue.offer(tmp);
|
||||||
if (send) {
|
if (send) {
|
||||||
send(tmp);
|
sendAll(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 记录当前读到的位置
|
// 记录当前读到的位置
|
||||||
this.randomFile.seek(currentLength);
|
this.randomFile.seek(currentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void send(String msg) {
|
private void sendAll(String msg) {
|
||||||
Iterator<Session> iterator = socketSessions.iterator();
|
Iterator<Session> iterator = socketSessions.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Session socketSession = iterator.next();
|
Session socketSession = iterator.next();
|
||||||
@ -164,7 +175,7 @@ public class FileTailWatcher implements Runnable {
|
|||||||
this.read(true);
|
this.read(true);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
DefaultSystemLog.ERROR().error("读取文件发送异常", e);
|
DefaultSystemLog.ERROR().error("读取文件发送异常", e);
|
||||||
this.send("读取文件发生异常:" + e.getMessage());
|
this.sendAll("读取文件发生异常:" + e.getMessage());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -174,13 +185,7 @@ public class FileTailWatcher implements Runnable {
|
|||||||
}
|
}
|
||||||
// 通知客户端
|
// 通知客户端
|
||||||
if (socketSessions.size() > 0) {
|
if (socketSessions.size() > 0) {
|
||||||
for (Session socketSession : socketSessions) {
|
this.sendAll("服务主动关闭日志文件");
|
||||||
try {
|
|
||||||
SocketSessionUtil.send(socketSession, "服务主动关闭日志文件");
|
|
||||||
} catch (Exception e) {
|
|
||||||
DefaultSystemLog.ERROR().error("发送消息失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
IoUtil.close(this.randomFile);
|
IoUtil.close(this.randomFile);
|
||||||
// 清理线程记录
|
// 清理线程记录
|
||||||
|
@ -92,7 +92,6 @@ public class LogWebSocketHandle {
|
|||||||
}
|
}
|
||||||
String projectId = json.getString("projectId");
|
String projectId = json.getString("projectId");
|
||||||
ProjectInfoService projectInfoService = SpringUtil.getBean(ProjectInfoService.class);
|
ProjectInfoService projectInfoService = SpringUtil.getBean(ProjectInfoService.class);
|
||||||
// SocketSessionUtil socketSession = getItem(session);
|
|
||||||
ProjectInfoModel projectInfoModel = null;
|
ProjectInfoModel projectInfoModel = null;
|
||||||
try {
|
try {
|
||||||
projectInfoModel = projectInfoService.getItem(projectId);
|
projectInfoModel = projectInfoService.getItem(projectId);
|
||||||
|
@ -17,11 +17,8 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class ExtConfigEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
public class ExtConfigEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||||
|
|
||||||
private static ConfigurableEnvironment configurableEnvironment;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||||
configurableEnvironment = environment;
|
|
||||||
YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
|
YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
|
||||||
Resource resource = ExtConfigBean.getResource();
|
Resource resource = ExtConfigBean.getResource();
|
||||||
try {
|
try {
|
||||||
|
@ -3,9 +3,6 @@ package cn.keepbx.jpom.system.init;
|
|||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.resource.ResourceUtil;
|
import cn.hutool.core.io.resource.ResourceUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.system.JavaRuntimeInfo;
|
|
||||||
import cn.hutool.system.SystemUtil;
|
|
||||||
import cn.jiangzeyin.common.DefaultSystemLog;
|
import cn.jiangzeyin.common.DefaultSystemLog;
|
||||||
import cn.jiangzeyin.common.JsonMessage;
|
import cn.jiangzeyin.common.JsonMessage;
|
||||||
import cn.jiangzeyin.common.PreLoadClass;
|
import cn.jiangzeyin.common.PreLoadClass;
|
||||||
@ -45,7 +42,6 @@ public class CheckRunCommand {
|
|||||||
*/
|
*/
|
||||||
@PreLoadMethod
|
@PreLoadMethod
|
||||||
private static void checkSh() throws Exception {
|
private static void checkSh() throws Exception {
|
||||||
tipTail();
|
|
||||||
try {
|
try {
|
||||||
ConfigBean.getInstance().getRamCommandPath();
|
ConfigBean.getInstance().getRamCommandPath();
|
||||||
} catch (ConfigException e) {
|
} catch (ConfigException e) {
|
||||||
@ -60,36 +56,6 @@ public class CheckRunCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void tipTail() {
|
|
||||||
if (!AbstractCommander.OS_INFO.isWindows()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JavaRuntimeInfo javaRuntimeInfo = SystemUtil.getJavaRuntimeInfo();
|
|
||||||
String path = javaRuntimeInfo.getLibraryPath();
|
|
||||||
String[] paths = StrUtil.splitToArray(path, ';');
|
|
||||||
for (String itemPath : paths) {
|
|
||||||
String item = FileUtil.normalize(itemPath);
|
|
||||||
int index = item.indexOf(StrUtil.COLON);
|
|
||||||
if (index < 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
item = item.substring(index + 1);
|
|
||||||
if (item.startsWith(StrUtil.SLASH)) {
|
|
||||||
item = item.substring(1);
|
|
||||||
}
|
|
||||||
if (item.endsWith(StrUtil.SLASH)) {
|
|
||||||
item = item.substring(0, item.length() - 1);
|
|
||||||
}
|
|
||||||
if (StrUtil.equalsIgnoreCase("WINDOWS/system32", item)) {
|
|
||||||
File file = new File(itemPath, "tail.exe");
|
|
||||||
if (!file.exists()) {
|
|
||||||
DefaultSystemLog.LOG().info("还未配置tail:详情查看>> https://gitee.com/keepbx/jpom/blob/master/doc/windows-tail.md");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查运行数据
|
* 检查运行数据
|
||||||
*/
|
*/
|
||||||
|
@ -3,6 +3,8 @@ package cn.keepbx.jpom.util;
|
|||||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 定长队列
|
||||||
|
*
|
||||||
* @author jiangzeyin
|
* @author jiangzeyin
|
||||||
* @date 2019/3/16
|
* @date 2019/3/16
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user