use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class ManageEditProjectController method releaseOutGiving.
@RequestMapping(value = "releaseOutGiving", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String releaseOutGiving() {
NodeProjectInfoModel nodeProjectInfoModel = tryGetProjectInfoModel();
if (nodeProjectInfoModel != null) {
nodeProjectInfoModel.setOutGivingProject(false);
projectInfoService.updateItem(nodeProjectInfoModel);
}
return JsonMessage.getString(200, "ok");
}
use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class ProjectListController method getProjectItem.
/**
* 获取项目的信息
*
* @param id id
* @return item
* @see NodeProjectInfoModel
*/
@RequestMapping(value = "getProjectItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String getProjectItem(String id) {
NodeProjectInfoModel nodeProjectInfoModel = projectInfoService.getItem(id);
if (nodeProjectInfoModel != null) {
RunMode runMode = nodeProjectInfoModel.getRunMode();
if (runMode != RunMode.Dsl && runMode != RunMode.File) {
// 返回实际执行的命令
String command = AbstractProjectCommander.getInstance().buildJavaCommand(nodeProjectInfoModel, null);
nodeProjectInfoModel.setRunCommand(command);
}
//
List<NodeProjectInfoModel.JavaCopyItem> javaCopyItemList = nodeProjectInfoModel.getJavaCopyItemList();
if (javaCopyItemList != null) {
for (NodeProjectInfoModel.JavaCopyItem javaCopyItem : javaCopyItemList) {
File logBack = nodeProjectInfoModel.getLogBack(javaCopyItem);
File log = nodeProjectInfoModel.getLog(javaCopyItem);
javaCopyItem.setLogBack(FileUtil.getAbsolutePath(logBack));
javaCopyItem.setLog(FileUtil.getAbsolutePath(log));
}
}
}
return JsonMessage.getString(200, "", nodeProjectInfoModel);
}
use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class IndexController method status.
/**
* 返回节点项目状态信息
*
* @return array
*/
@RequestMapping(value = "status", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String status() {
List<NodeProjectInfoModel> nodeProjectInfoModels = projectInfoService.list();
List<NodeScriptModel> list = nodeScriptServer.list();
JSONObject jsonObject = new JSONObject();
jsonObject.put("javaVirtualCount", JvmUtil.getJavaVirtualCount());
JpomManifest instance = JpomManifest.getInstance();
jsonObject.put("osName", instance.getOsName());
jsonObject.put("jpomVersion", instance.getVersion());
jsonObject.put("javaVersion", SystemUtil.getJavaRuntimeInfo().getVersion());
// 获取JVM中内存总大小
long totalMemory = SystemUtil.getTotalMemory();
jsonObject.put("totalMemory", FileUtil.readableFileSize(totalMemory));
//
long freeMemory = SystemUtil.getFreeMemory();
jsonObject.put("freeMemory", FileUtil.readableFileSize(freeMemory));
//
jsonObject.put("count", CollUtil.size(nodeProjectInfoModels));
jsonObject.put("scriptCount", CollUtil.size(list));
// 运行时间
jsonObject.put("runTime", instance.getUpTimeStr());
jsonObject.put("runTimeLong", instance.getUpTime());
return JsonMessage.getString(200, "", jsonObject);
}
use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class ConsoleService method execCommand.
/**
* 执行shell命令
*
* @param consoleCommandOp 执行的操作
* @param nodeProjectInfoModel 项目信息
* @param copyItem 副本信息
* @return 执行结果
* @throws Exception 异常
*/
public String execCommand(ConsoleCommandOp consoleCommandOp, NodeProjectInfoModel nodeProjectInfoModel, NodeProjectInfoModel.JavaCopyItem copyItem) throws Exception {
String result;
AbstractProjectCommander abstractProjectCommander = AbstractProjectCommander.getInstance();
// 执行命令
switch(consoleCommandOp) {
case restart:
result = abstractProjectCommander.restart(nodeProjectInfoModel, copyItem);
break;
case start:
result = abstractProjectCommander.start(nodeProjectInfoModel, copyItem);
break;
case stop:
result = abstractProjectCommander.stop(nodeProjectInfoModel, copyItem);
break;
case status:
{
result = abstractProjectCommander.status(nodeProjectInfoModel, copyItem);
break;
}
case top:
case showlog:
default:
throw new IllegalArgumentException(consoleCommandOp + " error");
}
// 通知日志刷新
if (consoleCommandOp == ConsoleCommandOp.start || consoleCommandOp == ConsoleCommandOp.restart) {
// 修改 run lib 使用情况
NodeProjectInfoModel modify = projectInfoService.getItem(nodeProjectInfoModel.getId());
//
if (copyItem != null) {
NodeProjectInfoModel.JavaCopyItem copyItem1 = modify.findCopyItem(copyItem.getId());
copyItem1.setModifyTime(DateUtil.now());
}
modify.setRunLibDesc(nodeProjectInfoModel.getUseLibDesc());
try {
projectInfoService.updateItem(modify);
} catch (Exception ignored) {
}
}
return result;
}
use of io.jpom.model.data.NodeProjectInfoModel in project Jpom by dromara.
the class ProjectFileControl method batchDelete.
@RequestMapping(value = "batch_delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public String batchDelete(@RequestBody DiffFileVo diffFileVo) {
String id = diffFileVo.getId();
NodeProjectInfoModel projectInfoModel = super.getProjectInfoModel(id);
//
List<DiffFileVo.DiffItem> data = diffFileVo.getData();
Assert.notEmpty(data, "没有要对比的数据");
//
String path = projectInfoModel.allLib();
for (DiffFileVo.DiffItem datum : data) {
File file = FileUtil.file(path, datum.getName());
if (FileUtil.del(file)) {
continue;
}
return JsonMessage.getString(500, "删除失败");
}
return JsonMessage.getString(200, "删除成功");
}
Aggregations