use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class LogBackController method logSize.
@RequestMapping(value = "logSize", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String logSize(String id, String copyId) {
NodeProjectInfoModel nodeProjectInfoModel = getProjectInfoModel();
JSONObject jsonObject = new JSONObject();
//
NodeProjectInfoModel.JavaCopyItem copyItem = nodeProjectInfoModel.findCopyItem(copyId);
// 获取日志备份路径
File logBack = copyItem == null ? nodeProjectInfoModel.getLogBack() : nodeProjectInfoModel.getLogBack(copyItem);
boolean logBackBool = logBack.exists() && logBack.isDirectory();
jsonObject.put("logBack", logBackBool);
String info = projectInfoService.getLogSize(nodeProjectInfoModel, copyItem);
jsonObject.put("logSize", info);
return JsonMessage.getString(200, "", jsonObject);
}
use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class LogBackController method console.
@RequestMapping(value = "logBack", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String console(String copyId) {
// 查询项目路径
NodeProjectInfoModel pim = getProjectInfoModel();
NodeProjectInfoModel.JavaCopyItem copyItem = pim.findCopyItem(copyId);
JSONObject jsonObject = new JSONObject();
File logBack = copyItem == null ? pim.getLogBack() : pim.getLogBack(copyItem);
if (logBack.exists() && logBack.isDirectory()) {
File[] filesAll = logBack.listFiles();
if (filesAll != null) {
JSONArray jsonArray = FileUtils.parseInfo(filesAll, true, null);
jsonObject.put("array", jsonArray);
}
}
jsonObject.put("id", pim.getId());
jsonObject.put("logPath", copyItem == null ? pim.getLog() : pim.getLog(copyItem));
jsonObject.put("logBackPath", logBack.getAbsolutePath());
return JsonMessage.getString(200, "", jsonObject);
}
use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class ProjectStatusController method restart.
@RequestMapping(value = "restart", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String restart(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "项目id 不正确") String id, String copyId) {
NodeProjectInfoModel item = projectInfoService.getItem(id);
Assert.notNull(item, "没有找到对应的项目");
NodeProjectInfoModel.JavaCopyItem copyItem = item.findCopyItem(copyId);
String result;
try {
result = consoleService.execCommand(ConsoleCommandOp.restart, item, copyItem);
boolean status = AbstractProjectCommander.getInstance().isRun(item, copyItem);
if (status) {
return JsonMessage.getString(200, result);
}
return JsonMessage.getString(201, "重启项目失败:" + result);
} catch (Exception e) {
DefaultSystemLog.getLog().error("获取项目pid 失败", e);
result = "error:" + e.getMessage();
return JsonMessage.getString(500, "重启项目异常:" + result);
}
}
use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class AgentWebSocketConsoleHandle method onOpen.
@OnOpen
public void onOpen(Session session) {
try {
if (super.checkAuthorize(session)) {
return;
}
String projectId = super.getParameters(session, "projectId");
String copyId = super.getParameters(session, "copyId");
// 判断项目
if (!JpomApplication.SYSTEM_ID.equals(projectId)) {
if (projectInfoService == null) {
projectInfoService = SpringUtil.getBean(ProjectInfoService.class);
}
NodeProjectInfoModel nodeProjectInfoModel = this.checkProject(projectId, copyId, session);
if (nodeProjectInfoModel == null) {
return;
}
//
SocketSessionUtil.send(session, "连接成功:" + nodeProjectInfoModel.getName());
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("socket 错误", e);
try {
SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!"));
session.close();
} catch (IOException e1) {
DefaultSystemLog.getLog().error(e1.getMessage(), e1);
}
}
}
use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class AgentWebSocketConsoleHandle method onMessage.
@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 (silentMsg(consoleCommandOp, session)) {
return;
}
String projectId = json.getString("projectId");
String copyId = json.getString("copyId");
NodeProjectInfoModel nodeProjectInfoModel = this.checkProject(projectId, copyId, session);
if (nodeProjectInfoModel == null) {
return;
}
runMsg(consoleCommandOp, session, nodeProjectInfoModel, copyId, json);
}
Aggregations