use of io.jpom.service.node.script.NodeScriptServer in project Jpom by dromara.
the class NodeScriptHandler method createLog.
/**
* 创建执行日志
*
* @param attributes 参数属性
* @return 执行ID
*/
private String createLog(Map<String, Object> attributes) {
NodeModel nodeInfo = (NodeModel) attributes.get("nodeInfo");
UserModel userModel = (UserModel) attributes.get("userInfo");
ScriptCacheModel dataItem = (ScriptCacheModel) attributes.get("dataItem");
NodeScriptExecuteLogServer logServer = SpringUtil.getBean(NodeScriptExecuteLogServer.class);
NodeScriptServer nodeScriptServer = SpringUtil.getBean(NodeScriptServer.class);
//
try {
BaseServerController.resetInfo(userModel);
//
ScriptCacheModel scriptCacheModel = new ScriptCacheModel();
scriptCacheModel.setId(dataItem.getId());
scriptCacheModel.setLastRunUser(userModel.getId());
nodeScriptServer.update(scriptCacheModel);
//
ScriptExecuteLogCacheModel scriptExecuteLogCacheModel = new ScriptExecuteLogCacheModel();
scriptExecuteLogCacheModel.setScriptId(dataItem.getScriptId());
scriptExecuteLogCacheModel.setNodeId(nodeInfo.getId());
scriptExecuteLogCacheModel.setScriptName(dataItem.getName());
scriptExecuteLogCacheModel.setTriggerExecType(0);
scriptExecuteLogCacheModel.setWorkspaceId(nodeInfo.getWorkspaceId());
logServer.insert(scriptExecuteLogCacheModel);
return scriptExecuteLogCacheModel.getId();
} finally {
BaseServerController.removeAll();
}
}
use of io.jpom.service.node.script.NodeScriptServer in project Jpom by dromara.
the class CheckMonitor method init.
@PreLoadMethod
private static void init() {
// 缓存检测调度
CronUtils.upsert("cache_manger_schedule", "0 0/10 * * * ?", () -> {
BuildUtil.reloadCacheSize();
ConfigBean.getInstance().dataSize();
});
// 开启版本检测调度
CronUtils.upsert("system_monitor", "0 0 0,12 * * ?", () -> {
try {
BackupInfoService backupInfoService = SpringUtil.getBean(BackupInfoService.class);
backupInfoService.checkAutoBackup();
//
RemoteVersion.loadRemoteInfo();
} catch (Exception e) {
DefaultSystemLog.getLog().error("系统调度执行出现错误", e);
}
});
// 拉取 脚本模版日志
CronUtils.upsert("pull_script_log", "0 0/1 * * * ?", () -> {
NodeService nodeService = SpringUtil.getBean(NodeService.class);
NodeScriptServer nodeScriptServer = SpringUtil.getBean(NodeScriptServer.class);
List<String> nodeIds = nodeScriptServer.hasScriptNode();
if (nodeIds == null) {
return;
}
for (String nodeId : nodeIds) {
NodeModel nodeModel = nodeService.getByKey(nodeId);
if (nodeModel == null) {
continue;
}
ThreadUtil.execute(() -> CheckMonitor.pullScriptLogItem(nodeModel));
}
});
// 异步加载
CheckMonitor.asyncLoad();
}
Aggregations