Search in sources :

Example 11 with NodeProjectInfoModel

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");
}
Also used : NodeProjectInfoModel(io.jpom.model.data.NodeProjectInfoModel) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with NodeProjectInfoModel

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);
}
Also used : NodeProjectInfoModel(io.jpom.model.data.NodeProjectInfoModel) RunMode(io.jpom.model.RunMode) File(java.io.File) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with 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);
}
Also used : NodeProjectInfoModel(io.jpom.model.data.NodeProjectInfoModel) NodeScriptModel(io.jpom.model.data.NodeScriptModel) JSONObject(com.alibaba.fastjson.JSONObject) JpomManifest(io.jpom.common.JpomManifest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with NodeProjectInfoModel

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;
}
Also used : NodeProjectInfoModel(io.jpom.model.data.NodeProjectInfoModel) AbstractProjectCommander(io.jpom.common.commander.AbstractProjectCommander)

Example 15 with NodeProjectInfoModel

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, "删除成功");
}
Also used : NodeProjectInfoModel(io.jpom.model.data.NodeProjectInfoModel) File(java.io.File) DiffFileVo(io.jpom.controller.manage.vo.DiffFileVo)

Aggregations

NodeProjectInfoModel (io.jpom.model.data.NodeProjectInfoModel)40 File (java.io.File)18 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 JSONObject (com.alibaba.fastjson.JSONObject)11 JSONArray (com.alibaba.fastjson.JSONArray)7 AgentWhitelist (io.jpom.model.data.AgentWhitelist)6 AbstractProjectCommander (io.jpom.common.commander.AbstractProjectCommander)5 Charset (java.nio.charset.Charset)5 DiffFileVo (io.jpom.controller.manage.vo.DiffFileVo)4 ConsoleService (io.jpom.service.manage.ConsoleService)4 CollStreamUtil (cn.hutool.core.collection.CollStreamUtil)3 CollUtil (cn.hutool.core.collection.CollUtil)3 Convert (cn.hutool.core.convert.Convert)3 FileUtil (cn.hutool.core.io.FileUtil)3 ThreadUtil (cn.hutool.core.thread.ThreadUtil)3 ArrayUtil (cn.hutool.core.util.ArrayUtil)3 BooleanUtil (cn.hutool.core.util.BooleanUtil)3 StrUtil (cn.hutool.core.util.StrUtil)3 SecureUtil (cn.hutool.crypto.SecureUtil)3 ServletUtil (cn.hutool.extra.servlet.ServletUtil)3