使用 @Slf4j 替换 DefaultSystemLog

This commit is contained in:
bwcx_jzy 2022-06-12 22:39:44 +08:00
parent 2b4612ff0a
commit 33d2363f0a
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
107 changed files with 743 additions and 554 deletions

View File

@ -27,6 +27,7 @@ import cn.hutool.extra.servlet.ServletUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import cn.jiangzeyin.common.JsonMessage;
import io.jpom.system.JpomRuntimeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ -41,6 +42,7 @@ import javax.servlet.http.HttpServletResponse;
* @since 2019/04/17
*/
@ControllerAdvice
@Slf4j
public class AgentExceptionHandler extends BaseExceptionHandler {
/**
@ -52,7 +54,7 @@ public class AgentExceptionHandler extends BaseExceptionHandler {
*/
@ExceptionHandler({JpomRuntimeException.class, RuntimeException.class, Exception.class})
public void defExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception e) {
DefaultSystemLog.getLog().error("controller " + request.getRequestURI(), e);
log.error("controller " + request.getRequestURI(), e);
if (e instanceof JpomRuntimeException) {
ServletUtil.write(response, JsonMessage.getString(500, e.getMessage()), MediaType.APPLICATION_JSON_VALUE);
} else {
@ -69,7 +71,7 @@ public class AgentExceptionHandler extends BaseExceptionHandler {
*/
@ExceptionHandler({IllegalArgumentException.class, IllegalStateException.class, ValidateException.class})
public void paramExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception e) {
DefaultSystemLog.getLog().error("controller " + request.getRequestURI(), e);
log.error("controller " + request.getRequestURI(), e);
ServletUtil.write(response, JsonMessage.getString(405, e.getMessage()), MediaType.APPLICATION_JSON_VALUE);
}
}

View File

@ -55,6 +55,7 @@ import io.jpom.util.CommandUtil;
import io.jpom.util.FileUtils;
import io.jpom.util.JvmUtil;
import io.jpom.util.ProjectCommanderUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.IOException;
@ -74,6 +75,7 @@ import java.util.jar.Manifest;
*
* @author Administrator
*/
@Slf4j
public abstract class AbstractProjectCommander {
public static final String RUNNING_TAG = "running";
@ -177,7 +179,7 @@ public abstract class AbstractProjectCommander {
CommandUtil.asyncExeLocalCommand(file, command);
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行命令失败", e);
log.error("执行命令失败", e);
}
});
}
@ -292,7 +294,7 @@ public abstract class AbstractProjectCommander {
try {
this.webHooks(nodeProjectInfoModel, javaCopyItem, type, other);
} catch (Exception e) {
DefaultSystemLog.getLog().error("project webhook {}", e.getMessage());
log.error("project webhook {}", e.getMessage());
}
});
}
@ -406,7 +408,7 @@ public abstract class AbstractProjectCommander {
return jarFile.getAbsolutePath() + "中没有找到对应的MainClass:" + mainClass;
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("解析jar", e);
log.error("解析jar", e);
return jarFile.getAbsolutePath() + " 解析错误:" + e.getMessage();
}
return null;
@ -436,7 +438,7 @@ public abstract class AbstractProjectCommander {
// 清空日志
String r = AbstractSystemCommander.getInstance().emptyLogFile(file);
if (StrUtil.isNotEmpty(r)) {
DefaultSystemLog.getLog().info(r);
log.info(r);
}
return "ok";
}
@ -497,7 +499,7 @@ public abstract class AbstractProjectCommander {
*/
private String getLinuxPsStatus(String tag) {
String execSystemCommand = CommandUtil.execSystemCommand("ps -ef | grep " + tag);
DefaultSystemLog.getLog().debug("getLinuxPsStatus {} {}", tag, execSystemCommand);
log.debug("getLinuxPsStatus {} {}", tag, execSystemCommand);
List<String> list = StrSplitter.splitTrim(execSystemCommand, StrUtil.LF, true);
for (String item : list) {
if (JvmUtil.checkCommandLineIsJpom(item, tag)) {
@ -588,7 +590,7 @@ public abstract class AbstractProjectCommander {
return StrUtil.DASHED;
}
String tag = JvmUtil.parseCommandJpomTag(virtualMachine);
DefaultSystemLog.getLog().debug("getJpomNameByPid pid: {} {} {}", pid, tag, virtualMachine);
log.debug("getJpomNameByPid pid: {} {} {}", pid, tag, virtualMachine);
ProjectInfoService projectInfoService = SpringUtil.getBean(ProjectInfoService.class);
NodeProjectInfoModel item = projectInfoService.getItem(tag);
if (item == null) {

View File

@ -30,6 +30,7 @@ import io.jpom.common.commander.impl.LinuxTomcatCommander;
import io.jpom.common.commander.impl.WindowsTomcatCommander;
import io.jpom.model.data.TomcatInfoModel;
import io.jpom.system.JpomRuntimeException;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
@ -39,6 +40,7 @@ import java.util.concurrent.TimeUnit;
*
* @author LF
*/
@Slf4j
public abstract class AbstractTomcatCommander {
private static AbstractTomcatCommander abstractTomcatCommander;
@ -107,7 +109,7 @@ public abstract class AbstractTomcatCommander {
}
protected void exec(String command, boolean close) {
DefaultSystemLog.getLog().info(command);
log.info(command);
try {
// 执行命令
Process process = Runtime.getRuntime().exec(command);
@ -119,7 +121,7 @@ public abstract class AbstractTomcatCommander {
process.destroy();
}
} catch (IOException | InterruptedException e) {
DefaultSystemLog.getLog().error("tomcat执行名称失败", e);
log.error("tomcat执行名称失败", e);
}
}
}

View File

@ -35,6 +35,7 @@ import com.alibaba.fastjson.JSONObject;
import io.jpom.common.commander.AbstractSystemCommander;
import io.jpom.model.system.ProcessModel;
import io.jpom.util.CommandUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.ArrayList;
@ -44,6 +45,7 @@ import java.util.List;
* @author jiangzeyin
* @since 2019/4/16
*/
@Slf4j
public class LinuxSystemCommander extends AbstractSystemCommander {
@Override
@ -249,7 +251,7 @@ public class LinuxSystemCommander extends AbstractSystemCommander {
CommandUtil.asyncExeLocalCommand(FileUtil.file(SystemUtil.getUserInfo().getHomeDir()), serviceName);
return "ok";
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行异常", e);
log.error("执行异常", e);
return "执行异常:" + e.getMessage();
}
}

View File

@ -33,6 +33,7 @@ import com.alibaba.fastjson.JSONObject;
import io.jpom.common.commander.AbstractSystemCommander;
import io.jpom.model.system.ProcessModel;
import io.jpom.util.CommandUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.ArrayList;
@ -41,6 +42,7 @@ import java.util.List;
/**
* @author User
*/
@Slf4j
public class MacOsSystemCommander extends AbstractSystemCommander {
@Override
@ -67,7 +69,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander {
jsonObject.put("memory", memory);
}
jsonObject.put("disk", getHardDisk());
DefaultSystemLog.getLog().info("Mac OS monitor data: {}", jsonObject.toJSONString());
log.info("Mac OS monitor data: {}", jsonObject.toJSONString());
return jsonObject;
}
@ -84,7 +86,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander {
return null;
}
double used = 0, free = 0;
DefaultSystemLog.getLog().debug("Mac Os mem info: {}", info);
log.debug("Mac Os mem info: {}", info);
int index = info.indexOf(CharPool.COLON) + 1;
String[] split = info.substring(index).split(StrUtil.COMMA);
for (String str : split) {
@ -97,7 +99,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander {
used = Convert.toDouble(value, 0.0);
}
}
DefaultSystemLog.getLog().debug("Mac OS mem: used: {}, unused: {}", used, free);
log.debug("Mac OS mem: used: {}, unused: {}", used, free);
return String.format("%.2f", used / (used + free) * 100);
}
@ -111,7 +113,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander {
if (StrUtil.isEmpty(info)) {
return null;
}
DefaultSystemLog.getLog().debug("Mac Os cpu info: {}", info);
log.debug("Mac Os cpu info: {}", info);
int i = info.indexOf(CharPool.COLON);
String[] split = info.substring(i + 1).split(StrUtil.COMMA);
for (String str : split) {
@ -152,9 +154,9 @@ public class MacOsSystemCommander extends AbstractSystemCommander {
ProcessModel processModel;
for (String item : list) {
processModel = new ProcessModel();
DefaultSystemLog.getLog().debug("process item: {}", item);
log.debug("process item: {}", item);
List<String> values = StrSplitter.splitTrim(item, StrUtil.SPACE, true);
//DefaultSystemLog.getLog().debug(JSON.toJSONString(values));
//log.debug(JSON.toJSONString(values));
processModel.setPid(Convert.toInt(values.get(0), 0));
//processModel.setPort(values.get(6));
processModel.setCommand(values.get(1));
@ -228,7 +230,7 @@ public class MacOsSystemCommander extends AbstractSystemCommander {
CommandUtil.asyncExeLocalCommand(FileUtil.file(SystemUtil.getUserInfo().getHomeDir()), serviceName);
return "ok";
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行异常", e);
log.error("执行异常", e);
return "执行异常:" + e.getMessage();
}
}

View File

@ -42,6 +42,7 @@ import io.jpom.model.data.NodeProjectInfoModel;
import io.jpom.service.WhitelistDirectoryService;
import io.jpom.service.manage.JdkInfoService;
import io.jpom.system.ConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
@ -61,6 +62,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/manage/")
@Slf4j
public class ManageEditProjectController extends BaseAgentController {
private final WhitelistDirectoryService whitelistDirectoryService;
@ -282,7 +284,7 @@ public class ManageEditProjectController extends BaseAgentController {
return JsonMessage.getString(200, "修改成功");
}
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
return JsonMessage.getString(500, "保存数据异常:" + e.getMessage());
}
}
@ -371,7 +373,7 @@ public class ManageEditProjectController extends BaseAgentController {
}
return JsonMessage.getString(200, "删除成功!");
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
return JsonMessage.getString(500, "删除异常:" + e.getMessage());
}
}

View File

@ -36,6 +36,7 @@ import io.jpom.model.data.NodeProjectInfoModel;
import io.jpom.script.ProjectFileBackupUtil;
import io.jpom.util.CommandUtil;
import io.jpom.util.FileUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
@ -59,6 +60,7 @@ import java.util.stream.Collectors;
*/
@RestController
@RequestMapping(value = "/manage/file/")
@Slf4j
public class ProjectFileBackupController extends BaseAgentController {
/**
@ -132,7 +134,7 @@ public class ProjectFileBackupController extends BaseAgentController {
}
ServletUtil.write(response, file);
} catch (Exception e) {
DefaultSystemLog.getLog().error("下载文件异常", e);
log.error("下载文件异常", e);
ServletUtil.write(response, "下载文件异常:" + e.getMessage(), MediaType.TEXT_HTML_VALUE);
}
}

View File

@ -52,6 +52,7 @@ import io.jpom.service.manage.ConsoleService;
import io.jpom.socket.ConsoleCommandOp;
import io.jpom.system.AgentConfigBean;
import io.jpom.util.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
@ -73,6 +74,7 @@ import java.util.stream.Collectors;
*/
@RestController
@RequestMapping(value = "/manage/file/")
@Slf4j
public class ProjectFileControl extends BaseAgentController {
private final ConsoleService consoleService;
@ -208,7 +210,7 @@ public class ProjectFileControl extends BaseAgentController {
CompressionFileUtil.unCompress(file, lib);
} finally {
if (!FileUtil.del(file)) {
DefaultSystemLog.getLog().error("删除文件失败:" + file.getPath());
log.error("删除文件失败:" + file.getPath());
}
}
} else {
@ -233,7 +235,7 @@ public class ProjectFileControl extends BaseAgentController {
try {
consoleService.execCommand(ConsoleCommandOp.restart, pim, javaCopyItem);
} catch (Exception e) {
DefaultSystemLog.getLog().error("重启副本集失败", e);
log.error("重启副本集失败", e);
}
}));
}
@ -275,7 +277,7 @@ public class ProjectFileControl extends BaseAgentController {
}
return true;
} catch (Exception e) {
DefaultSystemLog.getLog().error("重复失败", e);
log.error("重复失败", e);
// 完整重启不再继续剩余的节点项目
return afterOpt != AfterOpt.Order_Must_Restart;
}
@ -415,7 +417,7 @@ public class ProjectFileControl extends BaseAgentController {
}
ServletUtil.write(getResponse(), file);
} catch (Exception e) {
DefaultSystemLog.getLog().error("下载文件异常", e);
log.error("下载文件异常", e);
}
return "下载失败。请刷新页面后重试";
}
@ -449,13 +451,13 @@ public class ProjectFileControl extends BaseAgentController {
CompressionFileUtil.unCompress(downloadFile, file);
} finally {
if (!FileUtil.del(downloadFile)) {
DefaultSystemLog.getLog().error("删除文件失败:" + file.getPath());
log.error("删除文件失败:" + file.getPath());
}
}
}
return JsonMessage.getString(200, "下载成功文件大小:" + FileUtil.readableFileSize(downloadFile));
} catch (Exception e) {
DefaultSystemLog.getLog().error("下载远程文件异常", e);
log.error("下载远程文件异常", e);
return JsonMessage.getString(500, "下载远程文件失败:" + e.getMessage());
} finally {
ProjectFileBackupUtil.checkDiff(pim.getId(), pim.allLib(), backupId, pim.dslConfig());

View File

@ -29,6 +29,7 @@ import io.jpom.common.BaseAgentController;
import io.jpom.common.commander.AbstractProjectCommander;
import io.jpom.model.RunMode;
import io.jpom.model.data.NodeProjectInfoModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
@ -46,6 +47,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/manage/")
@Slf4j
public class ProjectListController extends BaseAgentController {
/**
@ -93,7 +95,7 @@ public class ProjectListController extends BaseAgentController {
List<NodeProjectInfoModel> nodeProjectInfoModels = projectInfoService.list();
return JsonMessage.getString(200, "查询成功!", nodeProjectInfoModels);
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
return JsonMessage.getString(500, "查询异常:" + e.getMessage());
}
}

View File

@ -36,6 +36,7 @@ import io.jpom.service.manage.ConsoleService;
import io.jpom.socket.ConsoleCommandOp;
import io.jpom.util.CommandUtil;
import io.jpom.util.JvmUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
@ -52,6 +53,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/manage/")
@Slf4j
public class ProjectStatusController extends BaseAgentController {
private final ConsoleService consoleService;
@ -77,7 +79,7 @@ public class ProjectStatusController extends BaseAgentController {
try {
pid = AbstractProjectCommander.getInstance().getPid(nodeProjectInfoModel, null);
} catch (Exception e) {
DefaultSystemLog.getLog().error("获取项目pid 失败", e);
log.error("获取项目pid 失败", e);
}
if (pid <= 0) {
Assert.state(JvmUtil.jpsNormal, "当前服务器 jps 命令异常,请检查 jdk 是否完整,以及 java 环境变量是否配置正确");
@ -125,7 +127,7 @@ public class ProjectStatusController extends BaseAgentController {
NodeProjectInfoModel projectInfoServiceItem = projectInfoService.getItem(item);
pid = AbstractProjectCommander.getInstance().getPid(projectInfoServiceItem, null);
} catch (Exception e) {
DefaultSystemLog.getLog().error("获取端口错误", e);
log.error("获取端口错误", e);
continue;
}
if (pid <= 0) {
@ -175,7 +177,7 @@ public class ProjectStatusController extends BaseAgentController {
continue;
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("获取端口错误", e);
log.error("获取端口错误", e);
continue;
}
itemObj = new JSONObject();
@ -205,7 +207,7 @@ public class ProjectStatusController extends BaseAgentController {
}
return JsonMessage.getString(201, "重启项目失败:" + result);
} catch (Exception e) {
DefaultSystemLog.getLog().error("获取项目pid 失败", e);
log.error("获取项目pid 失败", e);
result = "error:" + e.getMessage();
return JsonMessage.getString(500, "重启项目异常:" + result);
}
@ -227,7 +229,7 @@ public class ProjectStatusController extends BaseAgentController {
}
return JsonMessage.getString(201, "关闭项目失败:" + result);
} catch (Exception e) {
DefaultSystemLog.getLog().error("获取项目pid 失败", e);
log.error("获取项目pid 失败", e);
result = "error:" + e.getMessage();
return JsonMessage.getString(500, "关闭项目异常:" + result);
}
@ -248,7 +250,7 @@ public class ProjectStatusController extends BaseAgentController {
}
return JsonMessage.getString(201, "启动项目失败:" + result);
} catch (Exception e) {
DefaultSystemLog.getLog().error("获取项目pid 失败", e);
log.error("获取项目pid 失败", e);
result = "error:" + e.getMessage();
return JsonMessage.getString(500, "启动项目异常:" + result);
}

View File

@ -31,6 +31,7 @@ import io.jpom.common.BaseAgentController;
import io.jpom.common.commander.AbstractProjectCommander;
import io.jpom.model.data.NodeProjectInfoModel;
import io.jpom.util.FileUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
@ -48,6 +49,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "manage/log")
@Slf4j
public class LogBackController extends BaseAgentController {
@RequestMapping(value = "logSize", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ -76,7 +78,7 @@ public class LogBackController extends BaseAgentController {
}
return JsonMessage.getString(201, "重置失败:" + msg);
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
return JsonMessage.getString(500, "重置日志失败");
}
}
@ -113,7 +115,7 @@ public class LogBackController extends BaseAgentController {
return "没有对应文件";
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("下载文件异常", e);
log.error("下载文件异常", e);
}
return "下载失败。请刷新页面后重试";
}

View File

@ -36,6 +36,7 @@ import io.jpom.model.system.NetstatModel;
import io.jpom.model.system.ProcessModel;
import io.jpom.system.AgentConfigBean;
import io.jpom.util.CommandUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -53,6 +54,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/manage/")
@Slf4j
public class InternalController extends BaseAgentController {
/**
@ -174,7 +176,7 @@ public class InternalController extends BaseAgentController {
// jsonObject.put("nonHeapCommitted", FileUtil.readableFileSize(nonCommitted));
// return jsonObject;
// } catch (Exception e) {
// DefaultSystemLog.getLog().error(e.getMessage(), e);
// log.error(e.getMessage(), e);
// }
// return null;
// }
@ -202,7 +204,7 @@ public class InternalController extends BaseAgentController {
CommandUtil.execSystemCommand(command);
downLoad(getResponse(), fileName);
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
// getResponse().sendRedirect("internal?tag=" + tag);
}
return JsonMessage.getString(200, "");
@ -230,7 +232,7 @@ public class InternalController extends BaseAgentController {
CommandUtil.execSystemCommand(command);
downLoad(getResponse(), fileName);
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
// getResponse().sendRedirect("internal?tag=" + tag);
}
return JsonMessage.getString(200, "");

View File

@ -36,6 +36,7 @@ import io.jpom.model.data.CertModel;
import io.jpom.service.WhitelistDirectoryService;
import io.jpom.service.system.CertService;
import io.jpom.system.AgentConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
@ -58,6 +59,7 @@ import java.util.zip.ZipFile;
*/
@RestController
@RequestMapping(value = "/system/certificate")
@Slf4j
public class CertificateController extends BaseAgentController {
@Resource
@ -115,7 +117,7 @@ public class CertificateController extends BaseAgentController {
certService.updateItem(certModel);
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("证书文件", e);
log.error("证书文件", e);
return JsonMessage.getString(400, "解析证书文件失败:" + e.getMessage());
}
return JsonMessage.getString(200, "提交成功");

View File

@ -44,6 +44,7 @@ import io.jpom.service.WhitelistDirectoryService;
import io.jpom.service.system.NginxService;
import io.jpom.util.CommandUtil;
import io.jpom.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
@ -65,6 +66,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("/system/nginx")
@Slf4j
public class NginxController extends BaseAgentController {
@Resource
@ -183,13 +185,13 @@ public class NginxController extends BaseAgentController {
}
}
} catch (IOException e) {
DefaultSystemLog.getLog().error("解析失败", e);
log.error("解析失败", e);
return JsonMessage.getString(500, "解析失败");
}
try {
FileUtil.writeString(context, file, CharsetUtil.UTF_8);
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
return JsonMessage.getString(400, "操作失败:" + e.getMessage());
}
String msg = this.reloadNginx();
@ -202,11 +204,11 @@ public class NginxController extends BaseAgentController {
String format = StrUtil.format("{} -s reload", serviceName);
String msg = CommandUtil.execSystemCommand(format);
if (StrUtil.isNotEmpty(msg)) {
DefaultSystemLog.getLog().info(msg);
log.info(msg);
return "(" + msg + ")";
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("reload nginx error", e);
log.error("reload nginx error", e);
}
return StrUtil.EMPTY;
}
@ -267,7 +269,7 @@ public class NginxController extends BaseAgentController {
FileUtil.rename(file, file.getName() + "_back", false, true);
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("删除nginx", e);
log.error("删除nginx", e);
return JsonMessage.getString(400, "操作失败:" + e.getMessage());
}
}

View File

@ -36,6 +36,7 @@ import io.jpom.common.BaseAgentController;
import io.jpom.common.Const;
import io.jpom.common.JpomManifest;
import io.jpom.system.ExtConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
@ -56,6 +57,7 @@ import java.nio.charset.StandardCharsets;
*/
@RestController
@RequestMapping(value = "system")
@Slf4j
public class SystemConfigController extends BaseAgentController {
@RequestMapping(value = "getConfig.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ -79,7 +81,7 @@ public class SystemConfigController extends BaseAgentController {
ByteArrayResource resource = new ByteArrayResource(content.replace("\t", " ").getBytes(StandardCharsets.UTF_8));
yamlPropertySourceLoader.load("test", resource);
} catch (Exception e) {
DefaultSystemLog.getLog().warn("内容格式错误,请检查修正", e);
log.warn("内容格式错误,请检查修正", e);
return JsonMessage.getString(500, "内容格式错误,请检查修正:" + e.getMessage());
}
if (JpomManifest.getInstance().isDebug()) {

View File

@ -41,6 +41,7 @@ import io.jpom.service.manage.TomcatManageService;
import io.jpom.socket.AgentFileTailWatcher;
import io.jpom.util.LayuiTreeUtil;
import io.jpom.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -56,6 +57,7 @@ import java.util.concurrent.TimeUnit;
*/
@RestController
@RequestMapping(value = "/tomcat/")
@Slf4j
public class TomcatManageController extends BaseAgentController {
@Resource
@ -336,7 +338,7 @@ public class TomcatManageController extends BaseAgentController {
}
ServletUtil.write(getResponse(), file);
} catch (Exception e) {
DefaultSystemLog.getLog().error("下载文件异常", e);
log.error("下载文件异常", e);
}
return "下载失败。请刷新页面后重试";
}

View File

@ -36,6 +36,7 @@ import com.alibaba.fastjson.JSONObject;
import io.jpom.model.BaseModel;
import io.jpom.service.system.CertService;
import io.jpom.system.JpomRuntimeException;
import lombok.extern.slf4j.Slf4j;
import java.io.InputStream;
import java.security.PrivateKey;
@ -48,6 +49,7 @@ import java.util.Date;
*
* @author Arno
*/
@Slf4j
public class CertModel extends BaseModel {
private static final String KEY = "Jpom 管理系统";
@ -207,7 +209,7 @@ public class CertModel extends BaseModel {
jsonObject.put("keyPath", key);
return jsonObject;
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
} finally {
IoUtil.close(inputStream);
}

View File

@ -26,6 +26,7 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import io.jpom.model.BaseModel;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.FileOutputStream;
@ -34,6 +35,7 @@ import java.io.IOException;
/**
* @author lf
*/
@Slf4j
public class UploadFileModel extends BaseModel {
private long size = 0;
private long completeSize = 0;
@ -80,7 +82,7 @@ public class UploadFileModel extends BaseModel {
fileOutputStream.write(data);
fileOutputStream.flush();
} catch (IOException e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
}
}

View File

@ -26,6 +26,7 @@ import cn.hutool.core.util.StrUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import io.jpom.common.commander.AbstractProjectCommander;
import io.jpom.model.BaseJsonModel;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
@ -35,6 +36,7 @@ import java.io.IOException;
* @author jiangzeyin
* @since 2019/4/15
*/
@Slf4j
public class ProcessModel extends BaseJsonModel {
/**
* 进程id
@ -123,7 +125,7 @@ public class ProcessModel extends BaseJsonModel {
String jpomName = AbstractProjectCommander.getInstance().getJpomNameByPid(pid);
this.setJpomName(jpomName);
} catch (IOException e) {
DefaultSystemLog.getLog().error("解析进程失败", e);
log.error("解析进程失败", e);
}
}
}

View File

@ -38,6 +38,7 @@ import io.jpom.service.script.NodeScriptServer;
import io.jpom.system.ExtConfigBean;
import io.jpom.util.CommandUtil;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.ArrayList;
@ -52,6 +53,7 @@ import java.util.Map;
* @since 2022/1/15
*/
@Setter
@Slf4j
public class DslScriptBuilder extends BaseRunScript implements Runnable {
@ -75,7 +77,7 @@ public class DslScriptBuilder extends BaseRunScript implements Runnable {
List<String> command = StrUtil.splitTrim(args, StrUtil.SPACE);
command.add(0, script);
command.add(0, CommandUtil.EXECUTE_PREFIX);
DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE));
log.debug(CollUtil.join(command, StrUtil.SPACE));
if (environment != null) {
processBuilder.environment().putAll(environment);
}
@ -98,7 +100,7 @@ public class DslScriptBuilder extends BaseRunScript implements Runnable {
//
this.handle("execute done:" + waitFor + " time:" + DateUtil.now());
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行异常", e);
log.error("执行异常", e);
String msg = "执行异常:" + e.getMessage();
this.end(msg);
}
@ -128,7 +130,7 @@ public class DslScriptBuilder extends BaseRunScript implements Runnable {
result.add(0, "" + waitFor);
return CollUtil.join(result, StrUtil.CRLF);
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行异常", e);
log.error("执行异常", e);
return "执行异常:" + e.getMessage();
} finally {
this.close();

View File

@ -129,7 +129,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
try {
SocketSessionUtil.send(session, line);
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
}
});
}
@ -188,7 +188,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
this.end(jsonObject.toString());
this.handle("execute done:" + waitFor + " time:" + DateUtil.now());
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行异常", e);
log.error("执行异常", e);
this.end("执行异常:" + e.getMessage());
} finally {
this.close();
@ -208,7 +208,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
try {
SocketSessionUtil.send(session, msg);
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
}
iterator.remove();
}
@ -230,7 +230,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
try {
SocketSessionUtil.send(session, line);
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
iterator.remove();
}
}

View File

@ -27,6 +27,7 @@ import com.alibaba.fastjson.JSONObject;
import io.jpom.model.data.AgentWhitelist;
import io.jpom.system.AgentConfigBean;
import io.jpom.util.JsonFileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -39,6 +40,7 @@ import java.util.List;
* @since 2019/2/28
*/
@Service
@Slf4j
public class WhitelistDirectoryService extends BaseDataService {
/**
@ -54,7 +56,7 @@ public class WhitelistDirectoryService extends BaseDataService {
}
return jsonObject.toJavaObject(AgentWhitelist.class);
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
}
return new AgentWhitelist();
}

View File

@ -40,6 +40,7 @@ import io.jpom.service.WhitelistDirectoryService;
import io.jpom.system.AgentConfigBean;
import io.jpom.util.JsonFileUtil;
import io.jpom.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.File;
@ -54,6 +55,7 @@ import java.util.stream.Collectors;
* @author Arno
*/
@Service
@Slf4j
public class NginxService extends BaseDataService {
private final WhitelistDirectoryService whitelistDirectoryService;
@ -106,7 +108,7 @@ public class NginxService extends BaseDataService {
jsonObject.putAll(data);
}
} catch (IOException e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
}
return jsonObject;
@ -296,7 +298,7 @@ public class NginxService extends BaseDataService {
}
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
}
return jsonObject;
}

View File

@ -25,6 +25,7 @@ package io.jpom.socket;
import cn.hutool.core.io.FileUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import io.jpom.util.BaseFileTailWatcher;
import lombok.extern.slf4j.Slf4j;
import javax.websocket.Session;
import java.io.File;
@ -39,6 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @author jiangzeyin
* @since 2019/3/16
*/
@Slf4j
public class AgentFileTailWatcher<T> extends BaseFileTailWatcher<T> {
private static final ConcurrentHashMap<File, AgentFileTailWatcher<Session>> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>();
@ -60,14 +62,14 @@ public class AgentFileTailWatcher<T> extends BaseFileTailWatcher<T> {
*/
public static boolean addWatcher(File file, Session session) throws IOException {
if (!FileUtil.isFile(file)) {
DefaultSystemLog.getLog().warn("文件不存在或者是目录:" + file.getPath());
log.warn("文件不存在或者是目录:" + file.getPath());
return false;
}
AgentFileTailWatcher<Session> agentFileTailWatcher = CONCURRENT_HASH_MAP.computeIfAbsent(file, s -> {
try {
return new AgentFileTailWatcher<>(file);
} catch (Exception e) {
DefaultSystemLog.getLog().error("创建文件监听失败", e);
log.error("创建文件监听失败", e);
return null;
}
});

View File

@ -40,6 +40,7 @@ import io.jpom.service.manage.ProjectInfoService;
import io.jpom.util.BaseFileTailWatcher;
import io.jpom.util.FileSearchUtil;
import io.jpom.util.SocketSessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
@ -57,6 +58,7 @@ import java.util.function.Consumer;
*/
@ServerEndpoint(value = "/console")
@Component
@Slf4j
public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle {
private static ProjectInfoService projectInfoService;
@ -82,12 +84,12 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle {
SocketSessionUtil.send(session, "连接成功:" + nodeProjectInfoModel.getName());
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("socket 错误", e);
log.error("socket 错误", e);
try {
SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!"));
session.close();
} catch (IOException e1) {
DefaultSystemLog.getLog().error(e1.getMessage(), e1);
log.error(e1.getMessage(), e1);
}
}
}
@ -200,7 +202,7 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle {
break;
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行命令失败", e);
log.error("执行命令失败", e);
SocketSessionUtil.send(session, "执行命令失败,详情如下:");
SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e));
return;
@ -217,7 +219,7 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle {
if (resultData != null) {
reqJson.putAll(resultData);
reqJson.put("JPOM_MSG", "JPOM_MSG");
DefaultSystemLog.getLog().info(reqJson.toString());
log.info(reqJson.toString());
SocketSessionUtil.send(session, reqJson.toString());
}
}
@ -268,7 +270,7 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle {
});
SocketSessionUtil.send(session, resultMsg);
} catch (Exception e) {
DefaultSystemLog.getLog().error("文件搜索失败", e);
log.error("文件搜索失败", e);
try {
SocketSessionUtil.send(session, "执行命令失败,详情如下:");
} catch (IOException ignored) {
@ -293,7 +295,7 @@ public class AgentWebSocketConsoleHandle extends BaseAgentWebSocketHandle {
SocketSessionUtil.send(session, "监听文件失败,可能文件不存在");
}
} catch (IOException io) {
DefaultSystemLog.getLog().error("监听日志变化", io);
log.error("监听日志变化", io);
SocketSessionUtil.send(session, io.getMessage());
}
}

View File

@ -31,6 +31,7 @@ import io.jpom.model.data.NodeScriptModel;
import io.jpom.script.ScriptProcessBuilder;
import io.jpom.service.script.NodeScriptServer;
import io.jpom.util.SocketSessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
@ -45,6 +46,7 @@ import java.io.IOException;
*/
@ServerEndpoint(value = "/script_run")
@Component
@Slf4j
public class AgentWebSocketScriptHandle extends BaseAgentWebSocketHandle {
private NodeScriptServer nodeScriptServer;
@ -70,12 +72,12 @@ public class AgentWebSocketScriptHandle extends BaseAgentWebSocketHandle {
}
SocketSessionUtil.send(session, "连接成功:" + nodeScriptModel.getName());
} catch (Exception e) {
DefaultSystemLog.getLog().error("socket 错误", e);
log.error("socket 错误", e);
try {
SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!"));
session.close();
} catch (IOException e1) {
DefaultSystemLog.getLog().error(e1.getMessage(), e1);
log.error(e1.getMessage(), e1);
}
}
}
@ -125,7 +127,7 @@ public class AgentWebSocketScriptHandle extends BaseAgentWebSocketHandle {
nodeScriptServer.updateItem(nodeScriptModel);
json.put("code", 200);
json.put("msg", "执行成功");
DefaultSystemLog.getLog().info(json.toString());
log.info(json.toString());
SocketSessionUtil.send(session, json.toString());
}

View File

@ -33,6 +33,7 @@ import io.jpom.model.data.TomcatInfoModel;
import io.jpom.service.manage.TomcatEditService;
import io.jpom.system.WebAopLog;
import io.jpom.util.SocketSessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
@ -50,6 +51,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
@ServerEndpoint(value = "/tomcat_log")
@Component
@Slf4j
public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle {
private TomcatEditService tomcatEditService;
@ -74,12 +76,12 @@ public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle {
}
SocketSessionUtil.send(session, "连接成功:" + (tomcatInfoModel == null ? "" : tomcatInfoModel.getName()));
} catch (Exception e) {
DefaultSystemLog.getLog().error("socket 错误", e);
log.error("socket 错误", e);
try {
SocketSessionUtil.send(session, JsonMessage.getString(500, "系统错误!"));
session.close();
} catch (IOException e1) {
DefaultSystemLog.getLog().error(e1.getMessage(), e1);
log.error(e1.getMessage(), e1);
}
}
}
@ -121,11 +123,11 @@ public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle {
AgentFileTailWatcher.addWatcher(file, session);
CACHE_FILE.put(session.getId(), file);
} catch (IOException io) {
DefaultSystemLog.getLog().error("监听日志变化", io);
log.error("监听日志变化", io);
SocketSessionUtil.send(session, io.getMessage());
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行命令失败", e);
log.error("执行命令失败", e);
SocketSessionUtil.send(session, "执行命令失败,详情如下:");
SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e));
}
@ -139,11 +141,11 @@ public class AgentWebSocketTomcatHandle extends BaseAgentWebSocketHandle {
try {
AgentFileTailWatcher.addWatcher(file, session);
} catch (IOException io) {
DefaultSystemLog.getLog().error("监听日志变化", io);
log.error("监听日志变化", io);
SocketSessionUtil.send(session, io.getMessage());
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行命令失败", e);
log.error("执行命令失败", e);
SocketSessionUtil.send(session, "执行命令失败,详情如下:");
SocketSessionUtil.send(session, ExceptionUtil.stacktraceToString(e));
}

View File

@ -36,6 +36,7 @@ import io.jpom.model.WebSocketMessageModel;
import io.jpom.model.data.UploadFileModel;
import io.jpom.system.AgentConfigBean;
import io.jpom.util.SocketSessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
@ -51,6 +52,7 @@ import java.util.Map;
*/
@ServerEndpoint(value = "/node_update")
@Component
@Slf4j
public class AgentWebSocketUpdateHandle extends BaseAgentWebSocketHandle {
private static final Map<String, UploadFileModel> UPLOAD_FILE_INFO = new HashMap<>();
@ -123,7 +125,7 @@ public class AgentWebSocketUpdateHandle extends BaseAgentWebSocketHandle {
JpomApplication.restart();
} catch (Exception e) {
result = "重启失败" + e.getMessage();
DefaultSystemLog.getLog().error("重启失败", e);
log.error("重启失败", e);
}
return result;
}

View File

@ -31,6 +31,7 @@ import com.alibaba.fastjson.JSONObject;
import io.jpom.system.AgentAuthorize;
import io.jpom.system.ConfigBean;
import io.jpom.util.SocketSessionUtil;
import lombok.extern.slf4j.Slf4j;
import javax.websocket.CloseReason;
import javax.websocket.Session;
@ -47,6 +48,7 @@ import static javax.websocket.CloseReason.CloseCodes.CANNOT_ACCEPT;
* @author jiangzeyin
* @since 2019/4/24
*/
@Slf4j
public abstract class BaseAgentWebSocketHandle {
private static final ConcurrentHashMap<String, String> USER = new ConcurrentHashMap<>();
@ -54,7 +56,7 @@ public abstract class BaseAgentWebSocketHandle {
protected String getParameters(Session session, String name) {
Map<String, List<String>> requestParameterMap = session.getRequestParameterMap();
Map<String, String> parameters = session.getPathParameters();
DefaultSystemLog.getLog().debug("web socket parameters: {} {}", JSONObject.toJSONString(requestParameterMap), parameters);
log.debug("web socket parameters: {} {}", JSONObject.toJSONString(requestParameterMap), parameters);
List<String> strings = requestParameterMap.get(name);
String value = CollUtil.join(strings, StrUtil.COMMA);
if (StrUtil.isEmpty(value)) {
@ -76,7 +78,7 @@ public abstract class BaseAgentWebSocketHandle {
try {
session.close(new CloseReason(CANNOT_ACCEPT, "授权信息错误"));
} catch (Exception e) {
DefaultSystemLog.getLog().error("socket 错误", e);
log.error("socket 错误", e);
}
return true;
}
@ -104,7 +106,7 @@ public abstract class BaseAgentWebSocketHandle {
SocketSessionUtil.send(session, "服务端发生异常" + ExceptionUtil.stacktraceToString(thr));
} catch (IOException ignored) {
}
DefaultSystemLog.getLog().error(session.getId() + "socket 异常", thr);
log.error(session.getId() + "socket 异常", thr);
}
protected String getOptUserName(Session session) {
@ -117,7 +119,7 @@ public abstract class BaseAgentWebSocketHandle {
try {
AgentFileTailWatcher.offline(session);
} catch (Exception e) {
DefaultSystemLog.getLog().error("关闭异常", e);
log.error("关闭异常", e);
}
// top
// TopManager.removeMonitor(session);

View File

@ -36,6 +36,7 @@ import io.jpom.model.data.NodeProjectInfoModel;
import io.jpom.service.manage.ProjectInfoService;
import io.jpom.system.AgentExtConfigBean;
import io.jpom.cron.CronUtils;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.List;
@ -47,6 +48,7 @@ import java.util.List;
* @since 2019/3/17
*/
@PreLoadClass
@Slf4j
public class AutoBackLog {
private static final String ID = "auto_back_log";
@ -62,7 +64,7 @@ public class AutoBackLog {
// 获取cron 表达式
String cron = StrUtil.emptyToDefault(AgentExtConfigBean.getInstance().autoBackConsoleCron, "none");
if ("none".equalsIgnoreCase(cron.trim())) {
//DefaultSystemLog.getLog().info("没有配置自动备份控制台日志表达式");
//log.info("没有配置自动备份控制台日志表达式");
//return;
cron = "0 0/10 * * * ?";
}
@ -85,7 +87,7 @@ public class AutoBackLog {
javaCopyItemList.forEach(javaCopyItem -> checkProject(projectInfoModel, javaCopyItem));
});
} catch (Exception e) {
DefaultSystemLog.getLog().error("定时备份日志失败", e);
log.error("定时备份日志失败", e);
}
});
}

View File

@ -47,6 +47,7 @@ import io.jpom.system.AgentConfigBean;
import io.jpom.system.AgentExtConfigBean;
import io.jpom.system.ConfigBean;
import io.jpom.util.JsonFileUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.FileNotFoundException;
@ -64,6 +65,7 @@ import java.util.stream.Collectors;
* @since 2019/8/6
*/
@PreLoadClass
@Slf4j
public class AutoRegSeverNode {
/**
@ -94,7 +96,7 @@ public class AutoRegSeverNode {
String body1 = execute.body();
JsonMessage<?> jsonMessage = JSON.parseObject(body1, JsonMessage.class);
if (jsonMessage.getCode() != HttpStatus.HTTP_OK) {
DefaultSystemLog.getLog().error("获取Server 安装id失败:" + jsonMessage);
log.error("获取Server 安装id失败:" + jsonMessage);
return;
}
String installId = jsonMessage.dataToString();
@ -115,7 +117,7 @@ public class AutoRegSeverNode {
serverRequest.form("type", eqInstall ? "update" : "add");
try (HttpResponse httpResponse = serverRequest.execute()) {
String body = httpResponse.body();
DefaultSystemLog.getLog().info("自动注册Server:" + body);
log.info("自动注册Server:" + body);
JsonMessage<?> regJsonMessage = JSON.parseObject(body, JsonMessage.class);
if (regJsonMessage.getCode() == HttpStatus.HTTP_OK) {
if (serverJson == null) {
@ -129,7 +131,7 @@ public class AutoRegSeverNode {
}
JsonFileUtil.saveJson(file.getAbsolutePath(), serverJson);
} else {
DefaultSystemLog.getLog().error("自动注册插件端失败:{}", body);
log.error("自动注册插件端失败:{}", body);
}
}
}

View File

@ -31,6 +31,7 @@ import cn.jiangzeyin.common.spring.SpringUtil;
import io.jpom.common.commander.AbstractProjectCommander;
import io.jpom.model.data.NodeProjectInfoModel;
import io.jpom.service.manage.ProjectInfoService;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.stream.Collectors;
@ -42,6 +43,7 @@ import java.util.stream.Collectors;
* @since 2021/12/10
*/
@PreLoadClass
@Slf4j
public class AutoStartProject {
@PreLoadMethod
@ -69,7 +71,7 @@ public class AutoStartProject {
}
}
} catch (Exception e) {
DefaultSystemLog.getLog().warn("自动启动项目失败:{} {}", nodeProjectInfoModel.getId(), e.getMessage());
log.warn("自动启动项目失败:{} {}", nodeProjectInfoModel.getId(), e.getMessage());
}
}
});

View File

@ -25,8 +25,10 @@ package io.jpom.common.commander.impl;
import cn.hutool.system.OsInfo;
import cn.hutool.system.SystemUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
@Slf4j
public class MacOSSystemCommanderTest {
private static OsInfo osInfo;
@ -40,9 +42,9 @@ public class MacOSSystemCommanderTest {
*/
@Test
public void testGetAllMonitor() {
DefaultSystemLog.getLog().info("is Mac: {}", osInfo.isMac());
DefaultSystemLog.getLog().info("is Linux: {}", osInfo.isLinux());
DefaultSystemLog.getLog().info("is MacOSX: {}", osInfo.isMacOsX());
log.info("is Mac: {}", osInfo.isMac());
log.info("is Linux: {}", osInfo.isLinux());
log.info("is MacOSX: {}", osInfo.isMacOsX());
// Mac OS
if (osInfo.isMac() || osInfo.isMacOsX()) {
// String result = CommandUtil.execSystemCommand("top -l 1 -n 1");
@ -60,9 +62,9 @@ public class MacOSSystemCommanderTest {
"PID COMMAND %CPU TIME #TH #WQ #PORTS MEM PURG CMPRS PGRP PPID STATE BOOSTS %CPU_ME %CPU_OTHRS UID FAULTS COW MSGSENT MSGRECV SYSBSD SYSMACH CSW PAGEINS IDLEW POWER INSTRS CYCLES USER #MREGS RPRVT VPRVT VSIZE KPRVT KSHRD\n" +
"35069 top 0.0 00:00.24 1/1 0 14 3428K 0B 0B 35069 28803 running *0[1] 0.00000 0.00000 0 1603 91 269374 134686 1834 138100 28 0 0 0.0 0 0 root N/A N/A N/A N/A N/A N/A";
DefaultSystemLog.getLog().info(result);
log.info(result);
DefaultSystemLog.getLog().info("-----------------------------");
log.info("-----------------------------");
MacOsSystemCommander macOSSystemCommander = new MacOsSystemCommander();
macOSSystemCommander.getAllMonitor();

View File

@ -43,6 +43,7 @@ import io.jpom.common.JpomManifest;
import io.jpom.common.Type;
import io.jpom.plugin.PluginFactory;
import io.jpom.util.CommandUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.core.env.Environment;
import org.springframework.http.converter.StringHttpMessageConverter;
@ -60,6 +61,7 @@ import java.util.concurrent.TimeUnit;
* @author jiangzeyin
* @since 2019/4/16
*/
@Slf4j
public class JpomApplication extends ApplicationBuilder {
/**
@ -202,7 +204,7 @@ public class JpomApplication extends ApplicationBuilder {
CommandUtil.asyncExeLocalCommand(scriptFile.getParentFile(), command);
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("重启自身异常", e);
log.error("重启自身异常", e);
}
});
}

View File

@ -38,6 +38,7 @@ import io.jpom.JpomApplication;
import io.jpom.system.ConfigBean;
import io.jpom.system.ExtConfigBean;
import io.jpom.util.JsonFileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.ContextClosedEvent;
@ -57,6 +58,7 @@ import java.util.List;
* @author jiangzeyin
* @since 2019/4/7
*/
@Slf4j
public class JpomApplicationEvent implements ApplicationEventClient {
private FileLock lock;
private FileOutputStream fileOutputStream;
@ -78,7 +80,7 @@ public class JpomApplicationEvent implements ApplicationEventClient {
try {
this.lockFile(jpomManifest.getPid());
} catch (IOException e) {
DefaultSystemLog.getLog().error("lockFile", e);
log.error("lockFile", e);
}
// 写入Jpom 信息 写入全局信息
File appJpomFile = instance.getApplicationJpomInfo(JpomApplication.getAppType());
@ -133,7 +135,7 @@ public class JpomApplicationEvent implements ApplicationEventClient {
lock = fileChannel.lock();
break;
} catch (OverlappingFileLockException | IOException e) {
DefaultSystemLog.getLog().warn("获取进程文件锁失败:" + e.getMessage());
log.warn("获取进程文件锁失败:" + e.getMessage());
}
ThreadUtil.sleep(100);
}
@ -151,7 +153,7 @@ public class JpomApplicationEvent implements ApplicationEventClient {
FileUtil.mkdir(file);
file = FileUtil.createTempFile("jpom", ".temp", file, true);
} catch (Exception e) {
DefaultSystemLog.getLog().error(StrUtil.format("Jpom Failed to create data directory, directory location{}," +
log.error(StrUtil.format("Jpom Failed to create data directory, directory location{}," +
"Please check whether the current user has permission to this directory or modify the configuration file{} jpom.path in is the path where the directory can be created", path, extConfigPath), e);
System.exit(-1);
}
@ -178,7 +180,7 @@ public class JpomApplicationEvent implements ApplicationEventClient {
File oldJars = JpomManifest.getOldJarsPath();
FileUtil.mkdir(oldJars);
FileUtil.move(beforeJarFile, oldJars, true);
DefaultSystemLog.getLog().info("备份旧程序包:" + beforeJar);
log.info("备份旧程序包:" + beforeJar);
}
}
}

View File

@ -47,6 +47,7 @@ import io.jpom.system.ExtConfigBean;
import io.jpom.system.JpomRuntimeException;
import io.jpom.util.CommandUtil;
import io.jpom.util.JsonFileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import java.io.File;
@ -71,6 +72,7 @@ import java.util.zip.ZipFile;
* @author jiangzeyin
* @since 2019/4/7
*/
@Slf4j
public class JpomManifest {
private volatile static JpomManifest JPOM_MANIFEST;
@ -384,7 +386,7 @@ public class JpomManifest {
}
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("解析jar", e);
log.error("解析jar", e);
return new JsonMessage<>(500, " 解析错误:" + e.getMessage());
}
return new JsonMessage<>(200, "", jarVersion);

View File

@ -141,7 +141,7 @@ public class RemoteVersion extends BaseJsonModel {
RemoteVersion.cacheLoadTime(remoteVersion);
return remoteVersion;
} catch (Exception e) {
DefaultSystemLog.getLog().warn("获取远程版本信息失败:{} {}", e.getMessage(), body);
log.warn("获取远程版本信息失败:{} {}", e.getMessage(), body);
return null;
}
}
@ -172,7 +172,7 @@ public class RemoteVersion extends BaseJsonModel {
}
return loadTransitUrl(jumpUrl);
} catch (Exception e) {
DefaultSystemLog.getLog().warn("获取远程版本信息失败:{} {}", e.getMessage(), body);
log.warn("获取远程版本信息失败:{} {}", e.getMessage(), body);
return null;
}
}
@ -231,7 +231,7 @@ public class RemoteVersion extends BaseJsonModel {
}
remoteVersion = JSONObject.parseObject(fileStr, RemoteVersion.class);
} catch (Exception e) {
DefaultSystemLog.getLog().warn("解析远程版本信息失败:{} {}", e.getMessage(), fileStr);
log.warn("解析远程版本信息失败:{} {}", e.getMessage(), fileStr);
}
// 判断上次获取时间
Long lastTime = remoteVersion == null ? 0 : remoteVersion.getLastTime();

View File

@ -24,6 +24,7 @@ package io.jpom.controller;
import cn.jiangzeyin.common.DefaultSystemLog;
import cn.jiangzeyin.common.JsonMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.http.HttpStatus;
@ -42,6 +43,7 @@ import java.util.Map;
* @since 2021/3/17
* @see org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController
*/
@Slf4j
public abstract class BaseMyErrorController extends AbstractErrorController {
public static final String FILE_MAX_SIZE_MSG = "上传文件太大了,请重新选择一个较小的文件上传吧";
@ -58,7 +60,7 @@ public abstract class BaseMyErrorController extends AbstractErrorController {
}
Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
String requestUri = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI);
DefaultSystemLog.getLog().error("发生异常:" + statusCode + " " + requestUri);
log.error("发生异常:" + statusCode + " " + requestUri);
// 判断异常信息
Object attribute = request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
Map<String, Object> body = new HashMap<>(5);

View File

@ -32,6 +32,7 @@ import cn.hutool.cron.task.Task;
import cn.jiangzeyin.common.DefaultSystemLog;
import com.alibaba.fastjson.JSONObject;
import io.jpom.system.ExtConfigBean;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.Map;
@ -43,143 +44,144 @@ import java.util.stream.Collectors;
* @author bwcx_jzy
* @since 2019/7/12
**/
@Slf4j
public class CronUtils {
private static final Map<String, TaskStat> TASK_STAT = new ConcurrentHashMap<>(50);
private static final Map<String, TaskStat> TASK_STAT = new ConcurrentHashMap<>(50);
/**
* 任务统计
*/
private static class TaskStat {
/**
* 执行次数
*/
private int executeCount;
/**
* 失败次数
*/
private int failedCount;
/**
* 成功次数
*/
private int succeedCount;
/**
* 最后执行时间
*/
private Long lastExecuteTime;
}
/**
* 任务统计
*/
private static class TaskStat {
/**
* 执行次数
*/
private int executeCount;
/**
* 失败次数
*/
private int failedCount;
/**
* 成功次数
*/
private int succeedCount;
/**
* 最后执行时间
*/
private Long lastExecuteTime;
}
/**
* 开始
*/
public static void start() {
boolean matchSecond = ExtConfigBean.getInstance().getTimerMatchSecond();
// 开启秒级
CronUtil.setMatchSecond(matchSecond);
//
Scheduler scheduler = CronUtil.getScheduler();
//
boolean started = scheduler.isStarted();
if (started) {
return;
}
synchronized (CronUtils.class) {
started = scheduler.isStarted();
if (started) {
return;
}
CronUtil.start();
scheduler.addListener(new TaskListener() {
@Override
public void onStart(TaskExecutor executor) {
TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat());
taskStat.lastExecuteTime = SystemClock.now();
taskStat.executeCount++;
}
/**
* 开始
*/
public static void start() {
boolean matchSecond = ExtConfigBean.getInstance().getTimerMatchSecond();
// 开启秒级
CronUtil.setMatchSecond(matchSecond);
//
Scheduler scheduler = CronUtil.getScheduler();
//
boolean started = scheduler.isStarted();
if (started) {
return;
}
synchronized (CronUtils.class) {
started = scheduler.isStarted();
if (started) {
return;
}
CronUtil.start();
scheduler.addListener(new TaskListener() {
@Override
public void onStart(TaskExecutor executor) {
TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat());
taskStat.lastExecuteTime = SystemClock.now();
taskStat.executeCount++;
}
@Override
public void onSucceeded(TaskExecutor executor) {
TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat());
taskStat.succeedCount++;
}
@Override
public void onSucceeded(TaskExecutor executor) {
TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat());
taskStat.succeedCount++;
}
@Override
public void onFailed(TaskExecutor executor, Throwable exception) {
TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat());
taskStat.failedCount++;
DefaultSystemLog.getLog().error("定时任务异常", exception);
}
});
}
}
@Override
public void onFailed(TaskExecutor executor, Throwable exception) {
TaskStat taskStat = TASK_STAT.computeIfAbsent(executor.getCronTask().getId(), s -> new TaskStat());
taskStat.failedCount++;
log.error("定时任务异常", exception);
}
});
}
}
/**
* 获取任务列表
*
* @return list
*/
public static List<JSONObject> list() {
Scheduler scheduler = CronUtil.getScheduler();
TaskTable taskTable = scheduler.getTaskTable();
List<String> ids = taskTable.getIds();
return ids.stream().map(s -> {
TaskStat taskStat = TASK_STAT.get(s);
JSONObject jsonObject = new JSONObject();
jsonObject.put("taskId", s);
jsonObject.put("cron", scheduler.getPattern(s).toString());
if (taskStat != null) {
jsonObject.put("executeCount", taskStat.executeCount);
jsonObject.put("failedCount", taskStat.failedCount);
jsonObject.put("succeedCount", taskStat.succeedCount);
jsonObject.put("lastExecuteTime", taskStat.lastExecuteTime);
}
return jsonObject;
}).collect(Collectors.toList());
}
/**
* 获取任务列表
*
* @return list
*/
public static List<JSONObject> list() {
Scheduler scheduler = CronUtil.getScheduler();
TaskTable taskTable = scheduler.getTaskTable();
List<String> ids = taskTable.getIds();
return ids.stream().map(s -> {
TaskStat taskStat = TASK_STAT.get(s);
JSONObject jsonObject = new JSONObject();
jsonObject.put("taskId", s);
jsonObject.put("cron", scheduler.getPattern(s).toString());
if (taskStat != null) {
jsonObject.put("executeCount", taskStat.executeCount);
jsonObject.put("failedCount", taskStat.failedCount);
jsonObject.put("succeedCount", taskStat.succeedCount);
jsonObject.put("lastExecuteTime", taskStat.lastExecuteTime);
}
return jsonObject;
}).collect(Collectors.toList());
}
/**
* 添加任务 已经存在则不添加
*
* @param id 任务ID
* @param cron 表达式
* @param supplier 创建任务回调
*/
public static void add(String id, String cron, Supplier<Task> supplier) {
Scheduler scheduler = CronUtil.getScheduler();
Task task = scheduler.getTask(id);
if (task != null) {
return;
}
scheduler.schedule(id, cron, supplier.get());
//
CronUtils.start();
}
/**
* 添加任务 已经存在则不添加
*
* @param id 任务ID
* @param cron 表达式
* @param supplier 创建任务回调
*/
public static void add(String id, String cron, Supplier<Task> supplier) {
Scheduler scheduler = CronUtil.getScheduler();
Task task = scheduler.getTask(id);
if (task != null) {
return;
}
scheduler.schedule(id, cron, supplier.get());
//
CronUtils.start();
}
/**
* 添加任务自动去重
*
* @param id 任务ID
* @param cron 表达式
* @param task 任务作业
*/
public static void upsert(String id, String cron, Task task) {
Scheduler scheduler = CronUtil.getScheduler();
Task schedulerTask = scheduler.getTask(id);
if (schedulerTask != null) {
CronUtil.remove(id);
}
// 创建任务
CronUtil.schedule(id, cron, task);
//
CronUtils.start();
}
/**
* 添加任务自动去重
*
* @param id 任务ID
* @param cron 表达式
* @param task 任务作业
*/
public static void upsert(String id, String cron, Task task) {
Scheduler scheduler = CronUtil.getScheduler();
Task schedulerTask = scheduler.getTask(id);
if (schedulerTask != null) {
CronUtil.remove(id);
}
// 创建任务
CronUtil.schedule(id, cron, task);
//
CronUtils.start();
}
/**
* 停止定时任务
*
* @param id ID
*/
public static void remove(String id) {
CronUtil.remove(id);
}
/**
* 停止定时任务
*
* @param id ID
*/
public static void remove(String id) {
CronUtil.remove(id);
}
}

View File

@ -22,9 +22,11 @@
*/
package io.jpom.model;
import cn.hutool.log.StaticLog;
import cn.jiangzeyin.common.DefaultSystemLog;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -78,7 +80,7 @@ public interface BaseEnum {
map1.put(item.getCode(), item);
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
DefaultSystemLog.getLog().error("enum error", e);
StaticLog.error("enum error", e);
return null;
}
return map1;
@ -185,7 +187,7 @@ public interface BaseEnum {
jsonArray.add(jsonObject);
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
DefaultSystemLog.getLog().error("enum error", e);
StaticLog.error("enum error", e);
return null;
}
return jsonArray;

View File

@ -33,6 +33,7 @@ import com.alibaba.fastjson.JSONObject;
import io.jpom.common.BaseJpomController;
import io.jpom.model.BaseJsonModel;
import io.jpom.system.ExtConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import java.io.File;
@ -45,6 +46,7 @@ import java.util.*;
* @author jiangzeyin
* @since 2019/4/16
*/
@Slf4j
public class AgentWhitelist extends BaseJsonModel {
/**
* 项目目录白名单日志文件白名单
@ -148,7 +150,7 @@ public class AgentWhitelist extends BaseJsonModel {
try {
return CollUtil.join(jsonArray, StrUtil.CRLF);
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
}
return "";
}

View File

@ -138,7 +138,7 @@ public class PluginFactory implements ApplicationContextInitializer<Configurable
}
private static void addPlugin(String pluginName, File file) {
DefaultSystemLog.getLog().info("加载:{} 插件", pluginName);
log.info("加载:{} 插件", pluginName);
ClassLoader contextClassLoader = ClassLoaderUtil.getClassLoader();
JarClassLoader.loadJar((URLClassLoader) contextClassLoader, file);
}
@ -154,7 +154,7 @@ public class PluginFactory implements ApplicationContextInitializer<Configurable
.map(aClass -> new PluginItemWrap((Class<? extends IPlugin>) aClass))
.filter(pluginItemWrap -> {
if (StrUtil.isEmpty(pluginItemWrap.getName())) {
DefaultSystemLog.getLog().warn("plugin config name error:{}", pluginItemWrap.getClassName());
log.warn("plugin config name error:{}", pluginItemWrap.getClassName());
return false;
}
return true;

View File

@ -31,6 +31,7 @@ import cn.jiangzeyin.common.interceptor.BaseCallbackController;
import io.jpom.JpomApplication;
import io.jpom.common.JpomManifest;
import io.jpom.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
@ -46,6 +47,7 @@ import java.io.File;
*/
@Aspect
@Component
@Slf4j
public class WebAopLog extends PropertyDefinerBase {
private static volatile AopLogInterface aopLogInterface;
@ -80,7 +82,7 @@ public class WebAopLog extends PropertyDefinerBase {
}
}
if (consoleLogReqResponse && logResult != null) {
DefaultSystemLog.getLog().info(BaseCallbackController.getRequestAttributes().getRequest().getRequestURI() + " :" + logResult);
log.info(BaseCallbackController.getRequestAttributes().getRequest().getRequestURI() + " :" + logResult);
}
return proceed;
}

View File

@ -34,6 +34,7 @@ import io.jpom.common.JpomManifest;
import io.jpom.system.ConfigBean;
import io.jpom.system.ExtConfigBean;
import io.jpom.util.JvmUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpMethod;
import javax.servlet.http.HttpServletRequest;
@ -50,84 +51,85 @@ import java.util.Map;
* @since 2019/3/26
*/
@PreLoadClass(value = Integer.MIN_VALUE)
@Slf4j
public class CheckPath {
/**
* 判断是否重复运行
*/
@PreLoadMethod(2)
private static void checkDuplicateRun() {
try {
Class<?> appClass = JpomApplication.getAppClass();
String pid = String.valueOf(JpomManifest.getInstance().getPid());
Integer mainClassPid = JvmUtil.findMainClassPid(appClass.getName());
if (mainClassPid == null || pid.equals(ObjectUtil.toString(mainClassPid))) {
return;
}
DefaultSystemLog.getLog().warn("The Jpom program recommends that only one corresponding program be run on a machine" + JpomApplication.getAppType() + " pid:" + mainClassPid);
} catch (Exception e) {
DefaultSystemLog.getLog().error("检查异常", e);
}
}
/**
* 判断是否重复运行
*/
@PreLoadMethod(2)
private static void checkDuplicateRun() {
try {
Class<?> appClass = JpomApplication.getAppClass();
String pid = String.valueOf(JpomManifest.getInstance().getPid());
Integer mainClassPid = JvmUtil.findMainClassPid(appClass.getName());
if (mainClassPid == null || pid.equals(ObjectUtil.toString(mainClassPid))) {
return;
}
log.warn("The Jpom program recommends that only one corresponding program be run on a machine" + JpomApplication.getAppType() + " pid:" + mainClassPid);
} catch (Exception e) {
log.error("检查异常", e);
}
}
@PreLoadMethod(3)
private static void reqXssLog() {
if (!ExtConfigBean.getInstance().isConsoleLogReqXss()) {
// 不在控制台记录请求日志信息
DefaultSystemLog.setLogCallback(new DefaultSystemLog.LogCallback() {
@Override
public void log(DefaultSystemLog.LogType type, Object... log) {
//
if (type == DefaultSystemLog.LogType.REQUEST_ERROR) {
DefaultSystemLog.getLog().info(Arrays.toString(log));
}
}
@PreLoadMethod(3)
private static void reqXssLog() {
if (!ExtConfigBean.getInstance().isConsoleLogReqXss()) {
// 不在控制台记录请求日志信息
DefaultSystemLog.setLogCallback(new DefaultSystemLog.LogCallback() {
@Override
public void log(DefaultSystemLog.LogType type, Object... log) {
//
if (type == DefaultSystemLog.LogType.REQUEST_ERROR) {
CheckPath.log.info(Arrays.toString(log));
}
}
@Override
public void logStart(HttpServletRequest request, String id, String url, HttpMethod httpMethod, String ip, Map<String, String> parameters, Map<String, String> header) {
@Override
public void logStart(HttpServletRequest request, String id, String url, HttpMethod httpMethod, String ip, Map<String, String> parameters, Map<String, String> header) {
}
}
@Override
public void logError(String id, int status) {
@Override
public void logError(String id, int status) {
}
}
@Override
public void logTimeOut(String id, long time) {
@Override
public void logTimeOut(String id, long time) {
}
});
}
}
}
});
}
}
@PreLoadMethod(4)
private static void clearTemp() {
File file = ConfigBean.getInstance().getTempPath();
/**
* @author Hotstrip
* use Hutool's FileUtil.del method just put file as param not file's path
* or else, may be return Accessdenied exception
*/
try {
FileUtil.del(file);
} catch (Exception e) {
// Try again jzy 2021-07-31
DefaultSystemLog.getLog().warn("Attempt to delete temporary folder failed, try to handle read-only permission{}", e.getMessage());
List<File> files = FileUtil.loopFiles(file);
long count = files.stream().map(file12 -> file12.setWritable(true)).filter(aBoolean -> aBoolean).count();
DefaultSystemLog.getLog().warn("Cumulative number of files in temporary folder: {}, number of successful processing{}", CollUtil.size(files), count);
try {
FileUtil.del(file.toPath());
} catch (Exception e1) {
e1.addSuppressed(e);
boolean causedBy = ExceptionUtil.isCausedBy(e1, AccessDeniedException.class);
if (causedBy) {
DefaultSystemLog.getLog().error("清除临时文件失败,请手动清理:" + FileUtil.getAbsolutePath(file), e);
return;
}
DefaultSystemLog.getLog().error("清除临时文件失败,请检查目录:" + FileUtil.getAbsolutePath(file), e);
}
}
}
@PreLoadMethod(4)
private static void clearTemp() {
File file = ConfigBean.getInstance().getTempPath();
/**
* @author Hotstrip
* use Hutool's FileUtil.del method just put file as param not file's path
* or else, may be return Accessdenied exception
*/
try {
FileUtil.del(file);
} catch (Exception e) {
// Try again jzy 2021-07-31
log.warn("Attempt to delete temporary folder failed, try to handle read-only permission{}", e.getMessage());
List<File> files = FileUtil.loopFiles(file);
long count = files.stream().map(file12 -> file12.setWritable(true)).filter(aBoolean -> aBoolean).count();
log.warn("Cumulative number of files in temporary folder: {}, number of successful processing{}", CollUtil.size(files), count);
try {
FileUtil.del(file.toPath());
} catch (Exception e1) {
e1.addSuppressed(e);
boolean causedBy = ExceptionUtil.isCausedBy(e1, AccessDeniedException.class);
if (causedBy) {
log.error("清除临时文件失败,请手动清理:" + FileUtil.getAbsolutePath(file), e);
return;
}
log.error("清除临时文件失败,请检查目录:" + FileUtil.getAbsolutePath(file), e);
}
}
}
}

View File

@ -35,6 +35,7 @@ import io.jpom.common.Type;
import io.jpom.cron.IAsyncLoad;
import io.jpom.cron.ICron;
import io.jpom.system.ConfigBean;
import lombok.extern.slf4j.Slf4j;
import java.util.Map;
@ -43,6 +44,7 @@ import java.util.Map;
* @since Created Time 2021/8/2
*/
@PreLoadClass(value = Integer.MAX_VALUE)
@Slf4j
public class ConsoleStartSuccess {
@ -55,7 +57,7 @@ public class ConsoleStartSuccess {
cronMap.forEach((name, iCron) -> {
int startCron = iCron.startCron();
if (startCron > 0) {
DefaultSystemLog.getLog().debug("{} scheduling has been started:{}", name, startCron);
log.debug("{} scheduling has been started:{}", name, startCron);
}
});
Map<String, IAsyncLoad> asyncLoadMap = SpringUtil.getApplicationContext().getBeansOfType(IAsyncLoad.class);

View File

@ -31,6 +31,7 @@ import cn.jiangzeyin.common.DefaultSystemLog;
import io.jpom.plugin.PluginFactory;
import io.jpom.system.ExtConfigBean;
import io.jpom.system.JpomRuntimeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.socket.WebSocketSession;
import javax.websocket.Session;
@ -48,6 +49,7 @@ import java.util.Set;
* @author bwcx_jzy
* @since 2019/7/21
*/
@Slf4j
public abstract class BaseFileTailWatcher<T> {
protected File logFile;
@ -79,7 +81,7 @@ public abstract class BaseFileTailWatcher<T> {
String charsetName = (String) PluginFactory.getPlugin("charset-detector").execute(logFile);
detSet = StrUtil.isEmpty(charsetName) ? CharsetUtil.CHARSET_UTF_8 : CharsetUtil.charset(charsetName);
} catch (Exception e) {
DefaultSystemLog.getLog().warn("自动识别文件编码格式错误:{}", e.getMessage());
log.warn("自动识别文件编码格式错误:{}", e.getMessage());
detSet = CharsetUtil.CHARSET_UTF_8;
}
detSet = (detSet == StandardCharsets.US_ASCII) ? CharsetUtil.CHARSET_UTF_8 : detSet;
@ -112,7 +114,7 @@ public abstract class BaseFileTailWatcher<T> {
try {
this.send(socketSession, msg);
} catch (Exception e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
iterator.remove();
}
}

View File

@ -30,6 +30,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.system.SystemUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import io.jpom.system.ExtConfigBean;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.IOException;
@ -46,6 +47,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @author jiangzeyin
* @since 2019/4/15
*/
@Slf4j
public class CommandUtil {
/**
* 系统命令
@ -149,7 +151,7 @@ public class CommandUtil {
String[] cmd = commands.toArray(new String[]{});
result = exec(cmd, file);
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行命令异常", e);
log.error("执行命令异常", e);
result += e.getMessage();
}
return result;
@ -165,20 +167,20 @@ public class CommandUtil {
private static String exec(String[] cmd, File file) throws IOException {
Process process = new ProcessBuilder(cmd).directory(file).redirectErrorStream(true).start();
Charset charset;
boolean log;
boolean isLog;
try {
charset = ExtConfigBean.getInstance().getConsoleLogCharset();
log = true;
isLog = true;
} catch (Exception e) {
// 直接执行使用默认编码格式
charset = CharsetUtil.systemCharset();
// 不记录日志
log = false;
isLog = false;
}
charset = ObjectUtil.defaultIfNull(charset, CharsetUtil.defaultCharset());
String result = RuntimeUtil.getResult(process, charset);
if (log) {
DefaultSystemLog.getLog().debug("exec {} {} {}", charset.name(), Arrays.toString(cmd), result);
if (isLog) {
log.debug("exec {} {} {}", charset.name(), Arrays.toString(cmd), result);
}
return result;
}
@ -194,7 +196,7 @@ public class CommandUtil {
String newCommand = StrUtil.replace(command, StrUtil.CRLF, StrUtil.SPACE);
newCommand = StrUtil.replace(newCommand, StrUtil.LF, StrUtil.SPACE);
//
DefaultSystemLog.getLog().debug(newCommand);
log.debug(newCommand);
List<String> commands = getCommand();
commands.add(newCommand);
ProcessBuilder pb = new ProcessBuilder(commands);

View File

@ -30,6 +30,7 @@ import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.PrintWriter;
@ -42,6 +43,7 @@ import java.nio.charset.Charset;
* @since 2022/1/26
*/
@Builder
@Slf4j
public class LogRecorder implements AutoCloseable {
/**
* 文件
@ -77,7 +79,7 @@ public class LogRecorder implements AutoCloseable {
* @param throwable 堆栈信息
*/
public void error(String title, Throwable throwable) {
DefaultSystemLog.getLog().error(title, throwable);
log.error(title, throwable);
FileUtil.appendLines(CollectionUtil.toList(title), this.getFile(), this.getCharset());
String s = ExceptionUtil.stacktraceToString(throwable);
FileUtil.appendLines(CollectionUtil.toList(s), this.getFile(), this.getCharset());

View File

@ -25,6 +25,7 @@ package io.jpom.util;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
@ -37,6 +38,7 @@ import java.io.IOException;
* @author jiangzeyin
* @since 2018/9/29
*/
@Slf4j
public class SocketSessionUtil {
/**
*
@ -76,7 +78,7 @@ public class SocketSessionUtil {
exception = null;
break;
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败:" + tryCount, e);
log.error("发送消息失败:" + tryCount, e);
exception = e;
}
} while (tryCount <= ERROR_TRY_COUNT);
@ -110,7 +112,7 @@ public class SocketSessionUtil {
exception = null;
break;
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败:" + tryCount, e);
log.error("发送消息失败:" + tryCount, e);
exception = e;
}
} while (tryCount <= ERROR_TRY_COUNT);

View File

@ -25,6 +25,7 @@ package cn;
import cn.hutool.core.io.file.FileNameUtil;
import cn.hutool.core.util.StrUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import lombok.extern.slf4j.Slf4j;
import java.security.CodeSource;
@ -34,68 +35,69 @@ import java.security.CodeSource;
*
* @author Hotstrip
*/
@Slf4j
public final class VersionUtils {
private static final String VERSION = getVersion(VersionUtils.class, "1.0.0");
private static final String VERSION = getVersion(VersionUtils.class, "1.0.0");
private VersionUtils() {
}
private VersionUtils() {
}
/**
* Gets version.
*
* @return the version
*/
public static String getVersion() {
return VERSION;
}
/**
* Gets version.
*
* @return the version
*/
public static String getVersion() {
return VERSION;
}
/**
* Gets version.
*
* @param cls the cls
* @param defaultVersion the default version
* @return the version
*/
public static String getVersion(final Class<?> cls, final String defaultVersion) {
// find version info from MANIFEST.MF first
String version = cls.getPackage().getImplementationVersion();
if (StrUtil.isEmpty(version)) {
version = cls.getPackage().getSpecificationVersion();
}
if (!StrUtil.isEmpty(version)) {
return version;
}
// guess version fro jar file name if nothing's found from MANIFEST.MF
CodeSource codeSource = cls.getProtectionDomain().getCodeSource();
/**
* Gets version.
*
* @param cls the cls
* @param defaultVersion the default version
* @return the version
*/
public static String getVersion(final Class<?> cls, final String defaultVersion) {
// find version info from MANIFEST.MF first
String version = cls.getPackage().getImplementationVersion();
if (StrUtil.isEmpty(version)) {
version = cls.getPackage().getSpecificationVersion();
}
if (!StrUtil.isEmpty(version)) {
return version;
}
// guess version fro jar file name if nothing's found from MANIFEST.MF
CodeSource codeSource = cls.getProtectionDomain().getCodeSource();
if (codeSource == null) {
DefaultSystemLog.getLog().warn("No codeSource for class {} when getVersion, use default version {}", cls.getName(), defaultVersion);
return defaultVersion;
}
String file = codeSource.getLocation().getFile();
if (file != null && file.endsWith(FileNameUtil.EXT_JAR)) {
file = file.substring(0, file.length() - 4);
int i = file.lastIndexOf('/');
if (i >= 0) {
file = file.substring(i + 1);
}
i = file.indexOf("-");
if (i >= 0) {
file = file.substring(i + 1);
}
while (file.length() > 0 && !Character.isDigit(file.charAt(0))) {
i = file.indexOf("-");
if (i < 0) {
break;
}
file = file.substring(i + 1);
}
version = file;
}
// return default version if no version info is found
return StrUtil.isEmpty(version) ? defaultVersion : version;
}
if (codeSource == null) {
log.warn("No codeSource for class {} when getVersion, use default version {}", cls.getName(), defaultVersion);
return defaultVersion;
}
String file = codeSource.getLocation().getFile();
if (file != null && file.endsWith(FileNameUtil.EXT_JAR)) {
file = file.substring(0, file.length() - 4);
int i = file.lastIndexOf('/');
if (i >= 0) {
file = file.substring(i + 1);
}
i = file.indexOf("-");
if (i >= 0) {
file = file.substring(i + 1);
}
while (file.length() > 0 && !Character.isDigit(file.charAt(0))) {
i = file.indexOf("-");
if (i < 0) {
break;
}
file = file.substring(i + 1);
}
version = file;
}
// return default version if no version info is found
return StrUtil.isEmpty(version) ? defaultVersion : version;
}
}

View File

@ -63,6 +63,7 @@ import io.jpom.util.FileUtils;
import io.jpom.util.LogRecorder;
import io.jpom.util.StringUtil;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert;
@ -86,6 +87,7 @@ import java.util.stream.Collectors;
* @since 2022/1/26
*/
@Service
@Slf4j
public class BuildExecuteService {
/**
@ -807,7 +809,7 @@ public class BuildExecuteService {
try {
plugin.execute(webhook, map);
} catch (Exception e) {
DefaultSystemLog.getLog().error("WebHooks 调用错误", e);
log.error("WebHooks 调用错误", e);
}
});

View File

@ -46,6 +46,7 @@ import io.jpom.system.AgentException;
import io.jpom.system.AuthorizeException;
import io.jpom.system.ConfigBean;
import io.jpom.system.ServerExtConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@ -63,6 +64,7 @@ import java.util.Set;
* @author jiangzeyin
* @since 2019/4/16
*/
@Slf4j
public class NodeForward {
/**
@ -216,7 +218,7 @@ public class NodeForward {
private static AgentException responseException(Exception exception, NodeModel nodeModel) {
String message = exception.getMessage();
Throwable cause = exception.getCause();
DefaultSystemLog.getLog().error("node [{}] connect failed...message: [{}]", nodeModel.getName(), message);
log.error("node [{}] connect failed...message: [{}]", nodeModel.getName(), message);
if (exception instanceof IORuntimeException) {
if (cause instanceof java.net.ConnectException || cause instanceof java.net.SocketTimeoutException) {
return new AgentException(nodeModel.getName() + "节点网络连接异常或超时,请优先检查插件端运行状态再检查 IP 地址、" +
@ -302,7 +304,7 @@ public class NodeForward {
try {
httpRequest.form(s, multipartFile.getBytes(), multipartFile.getOriginalFilename());
} catch (IOException e) {
DefaultSystemLog.getLog().error("转发文件异常", e);
log.error("转发文件异常", e);
}
});
// @author jzy add timeout
@ -448,7 +450,7 @@ public class NodeForward {
urlQuery.add("name", URLUtil.encode(nodeModel.getLoginName()));
urlQuery.add("password", URLUtil.encode(nodeModel.getLoginPwd()));
String format = StrUtil.format("{}://{}{}?{}", ws, nodeModel.getUrl(), nodeUrl.getUrl(), urlQuery.toString());
DefaultSystemLog.getLog().debug("web socket url:{}", format);
log.debug("web socket url:{}", format);
return format;
}
@ -462,7 +464,7 @@ public class NodeForward {
int status = response.getStatus();
String body = response.body();
if (status != HttpStatus.HTTP_OK) {
DefaultSystemLog.getLog().warn("{} 响应异常 状态码错误:{} {}", nodeModel.getName(), status, body);
log.warn("{} 响应异常 状态码错误:{} {}", nodeModel.getName(), status, body);
throw new AgentException(nodeModel.getName() + " 节点响应异常,状态码错误:" + status);
}
return toJsonMessage(body);

View File

@ -41,6 +41,7 @@ import io.jpom.model.dto.UserLoginDto;
import io.jpom.service.user.UserBindWorkspaceService;
import io.jpom.service.user.UserService;
import io.jpom.util.TwoFactorAuthUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
@ -55,6 +56,7 @@ import java.util.List;
* @since 2019/2/22
*/
@RestController
@Slf4j
public class InstallController extends BaseServerController {
@ -108,7 +110,7 @@ public class InstallController extends BaseServerController {
BaseServerController.resetInfo(userModel);
userService.insert(userModel);
} catch (Exception e) {
DefaultSystemLog.getLog().error("初始化用户失败", e);
log.error("初始化用户失败", e);
return JsonMessage.getString(400, "初始化失败:" + e.getMessage());
}
//自动登录

View File

@ -52,6 +52,7 @@ import io.jpom.plugin.*;
import io.jpom.service.dblog.BuildInfoService;
import io.jpom.service.dblog.RepositoryService;
import io.jpom.system.JpomRuntimeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
@ -71,6 +72,7 @@ import java.util.stream.Collectors;
*/
@RestController
@Feature(cls = ClassFeature.BUILD_REPOSITORY)
@Slf4j
public class RepositoryController extends BaseServerController {
private final RepositoryService repositoryService;
@ -143,7 +145,7 @@ public class RepositoryController extends BaseServerController {
} catch (JpomRuntimeException jpomRuntimeException) {
throw jpomRuntimeException;
} catch (Exception e) {
DefaultSystemLog.getLog().warn("获取仓库分支失败", e);
log.warn("获取仓库分支失败", e);
return JsonMessage.toJson(500, "无法连接此仓库," + e.getMessage());
}
}
@ -423,7 +425,7 @@ public class RepositoryController extends BaseServerController {
if (StrUtil.startWith(repositoryModelReq.getRsaPrv(), URLUtil.FILE_URL_PREFIX)) {
String rsaPath = StrUtil.removePrefix(repositoryModelReq.getRsaPrv(), URLUtil.FILE_URL_PREFIX);
if (!FileUtil.exist(rsaPath)) {
DefaultSystemLog.getLog().warn("there is no rsa file... {}", rsaPath);
log.warn("there is no rsa file... {}", rsaPath);
return false;
}
} else {

View File

@ -46,6 +46,7 @@ import io.jpom.permission.Feature;
import io.jpom.permission.MethodFeature;
import io.jpom.service.system.SystemParametersServer;
import io.jpom.system.ServerConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
@ -69,6 +70,7 @@ import java.util.stream.Collectors;
@RequestMapping(value = "/node")
@SystemPermission(superUser = true)
@Feature(cls = ClassFeature.UPGRADE_NODE_LIST)
@Slf4j
public class NodeUpdateController extends BaseServerController {
private final SystemParametersServer systemParametersServer;
@ -216,7 +218,7 @@ public class NodeUpdateController extends BaseServerController {
try {
nodeService.testNode(nodeModel);
} catch (Exception e) {
DefaultSystemLog.getLog().warn("测试结果:{} {}", nodeModel.getUrl(), e.getMessage());
log.warn("测试结果:{} {}", nodeModel.getUrl(), e.getMessage());
return JsonMessage.getString(500, "节点连接失败:" + e.getMessage());
}
// 插入

View File

@ -52,7 +52,7 @@ public class InternalController extends BaseServerController {
@ResponseBody
public String getInternalData() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_internal_data).toString();
//DefaultSystemLog.getLog().info("data: {}", data == null ? "" : data.toString());
//log.info("data: {}", data == null ? "" : data.toString());
// return JsonMessage.getString(200, "success", data);
}

View File

@ -46,6 +46,7 @@ import io.jpom.model.data.UserModel;
import io.jpom.model.enums.BuildStatus;
import io.jpom.service.dblog.BuildInfoService;
import io.jpom.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.h2.util.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
@ -60,6 +61,7 @@ import java.util.stream.Collectors;
*/
@RestController
@NotLogin
@Slf4j
public class BuildTriggerApiController extends BaseJpomController {
private final BuildInfoService buildInfoService;
@ -188,7 +190,7 @@ public class BuildTriggerApiController extends BaseJpomController {
}).collect(Collectors.toList());
return JsonMessage.getString(200, "触发成功", collect);
} catch (Exception e) {
DefaultSystemLog.getLog().error("构建触发批量触发异常", e);
log.error("构建触发批量触发异常", e);
return JsonMessage.getString(500, "触发异常", e.getMessage());
}
}
@ -263,7 +265,7 @@ public class BuildTriggerApiController extends BaseJpomController {
}).collect(Collectors.toList());
return JsonMessage.getString(200, "", collect);
} catch (Exception e) {
DefaultSystemLog.getLog().error("获取构建状态异常", e);
log.error("获取构建状态异常", e);
return JsonMessage.getString(500, "发送异常", e.getMessage());
}
}

View File

@ -40,6 +40,7 @@ import io.jpom.model.data.NodeModel;
import io.jpom.model.data.WorkspaceModel;
import io.jpom.service.node.NodeService;
import io.jpom.service.system.WorkspaceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
@ -56,6 +57,7 @@ import java.util.stream.Collectors;
* @since 2019/8/5
*/
@RestController
@Slf4j
public class NodeInfoController extends AbstractController {
private static final Map<String, JSONObject> CACHE_RECEIVE_PUSH = new HashMap<>();
@ -113,7 +115,7 @@ public class NodeInfoController extends AbstractController {
try {
nodeService.testNode(model);
} catch (Exception e) {
DefaultSystemLog.getLog().warn("测试结果:{} {}", model.getUrl(), e.getMessage());
log.warn("测试结果:{} {}", model.getUrl(), e.getMessage());
return null;
}
return model;

View File

@ -53,6 +53,7 @@ import io.jpom.service.node.ProjectInfoCacheService;
import io.jpom.system.ConfigBean;
import io.jpom.system.ServerConfigBean;
import io.jpom.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
@ -76,6 +77,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping(value = "/outgiving")
@Feature(cls = ClassFeature.OUTGIVING)
@Slf4j
public class OutGivingProjectController extends BaseServerController {
private final OutGivingServer outGivingServer;
@ -248,7 +250,7 @@ public class OutGivingProjectController extends BaseServerController {
OutGivingRun.startRun(outGivingModel.getId(), downloadFile, getUser(), unzip);
return JsonMessage.getString(200, "分发成功");
} catch (Exception e) {
DefaultSystemLog.getLog().error("下载远程文件异常", e);
log.error("下载远程文件异常", e);
return JsonMessage.getString(500, "下载远程文件失败:" + e.getMessage());
}
}

View File

@ -49,6 +49,7 @@ import io.jpom.permission.MethodFeature;
import io.jpom.service.dblog.BuildInfoService;
import io.jpom.service.outgiving.OutGivingServer;
import io.jpom.service.node.ProjectInfoCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
@ -68,6 +69,7 @@ import java.util.List;
@RestController
@RequestMapping(value = "/outgiving")
@Feature(cls = ClassFeature.OUTGIVING)
@Slf4j
public class OutGivingProjectEditController extends BaseServerController {
private final OutGivingWhitelistService outGivingWhitelistService;
@ -210,7 +212,7 @@ public class OutGivingProjectEditController extends BaseServerController {
projectInfoCacheService.syncNode(nodeModel, outGivingModel.getId());
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("保存分发项目失败", e);
log.error("保存分发项目失败", e);
if (!edit) {
fail = true;
outGivingServer.delByKey(outGivingModel.getId());
@ -223,7 +225,7 @@ public class OutGivingProjectEditController extends BaseServerController {
deleteNodeProject(entry.get(0), userModel, outGivingModel.getId());
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("还原项目失败", e);
log.error("还原项目失败", e);
}
}
}

View File

@ -179,8 +179,8 @@ public class SshController extends BaseServerController {
sshModel.setConnectType(connectType.name());
// 获取允许编辑的后缀
String allowEditSuffix = getParameter("allowEditSuffix");
int timeOut = getParameterInt("timeOut", 5);
sshModel.setTimeOut(timeOut);
int timeout = getParameterInt("timeout", 5);
sshModel.setTimeout(timeout);
List<String> allowEditSuffixList = AgentWhitelist.parseToList(allowEditSuffix, "允许编辑的文件后缀不能为空");
sshModel.allowEditSuffix(allowEditSuffixList);
try {
@ -253,7 +253,7 @@ public class SshController extends BaseServerController {
String javaVersion = sshService.checkCommand(model, "java");
data.put("javaVersion", javaVersion);
} catch (Exception e) {
DefaultSystemLog.getLog().error("检查运行状态异常:{}", e.getMessage());
log.error("检查运行状态异常:{}", e.getMessage());
data.put("error", e.getMessage());
}
result.put(sshModel.getId(), data);

View File

@ -109,7 +109,7 @@ public class SshFileController extends BaseServerController {
try {
this.downloadFile(sshModel, path, name, response);
} catch (SftpException e) {
DefaultSystemLog.getLog().error("下载失败", e);
log.error("下载失败", e);
ServletUtil.write(response, "download error", MediaType.TEXT_HTML_VALUE);
}
}
@ -376,7 +376,7 @@ public class SshFileController extends BaseServerController {
}
return JsonMessage.getString(200, "删除成功");
} catch (Exception e) {
DefaultSystemLog.getLog().error("ssh删除文件异常", e);
log.error("ssh删除文件异常", e);
return JsonMessage.getString(400, "删除失败:" + e.getMessage());
} finally {
IoUtil.close(sftp);
@ -482,7 +482,7 @@ public class SshFileController extends BaseServerController {
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("ssh上传文件异常", e);
log.error("ssh上传文件异常", e);
return JsonMessage.getString(400, "上传失败:" + e.getMessage());
} finally {
JschUtil.close(channel);

View File

@ -53,6 +53,7 @@ import io.jpom.system.ConfigBean;
import io.jpom.system.ExtConfigBean;
import io.jpom.system.ServerConfigBean;
import io.jpom.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.FileUrlResource;
@ -80,6 +81,7 @@ import java.util.zip.ZipFile;
@RestController
@RequestMapping(value = "node/ssh")
@Feature(cls = ClassFeature.SSH)
@Slf4j
public class SshInstallAgentController extends BaseServerController {
private final SshService sshService;
@ -216,7 +218,7 @@ public class SshInstallAgentController extends BaseServerController {
}
String command = StrUtil.format("{}bash {} start upgrade", chmod, shPtah);
String result = sshService.exec(sshModel, command);
DefaultSystemLog.getLog().debug("ssh install agent node {} {}", command, result);
log.debug("ssh install agent node {} {}", command, result);
// 休眠 5 , 尝试 5
int waitCount = getParameterInt("waitCount", 5);
this.loopCheck(waitCount, nodeModel, sshModel, path, result);
@ -251,7 +253,7 @@ public class SshInstallAgentController extends BaseServerController {
waitCount = Math.max(waitCount, 5);
//int time = 3;
while (--waitCount >= 0) {
//DefaultSystemLog.getLog().debug("there is left {} / 3 times try to get authorize info", waitCount);
//log.debug("there is left {} / 3 times try to get authorize info", waitCount);
ThreadUtil.sleep(5, TimeUnit.SECONDS);
if (StrUtil.hasEmpty(nodeModel.getLoginName(), nodeModel.getLoginPwd())) {
String error = this.getAuthorize(sshModel, nodeModel, path);
@ -283,7 +285,7 @@ public class SshInstallAgentController extends BaseServerController {
nodeModel.setLoginPwd(autoUser.getAgentPwd());
nodeModel.setLoginName(autoUser.getAgentName());
} catch (Exception e) {
DefaultSystemLog.getLog().error("拉取授权信息失败:{}", e.getMessage());
log.error("拉取授权信息失败:{}", e.getMessage());
return "获取授权信息失败,请检查对应的插件端运行状态" + e.getMessage();
} finally {
FileUtil.del(saveFile);

View File

@ -216,7 +216,7 @@ public class BackupInfoController extends BaseServerController {
// 检查备份文件是否存在
File file = new File(backupInfoModel.getFilePath());
if (!FileUtil.exist(file)) {
//DefaultSystemLog.getLog().error("文件不存在,无法下载...backupId: {}", id);
//log.error("文件不存在,无法下载...backupId: {}", id);
ServletUtil.write(getResponse(), JsonMessage.getString(404, "文件不存在,无法下载"), ContentType.JSON.toString());
return;
}

View File

@ -55,6 +55,7 @@ import io.jpom.service.system.SystemParametersServer;
import io.jpom.system.ExtConfigBean;
import io.jpom.system.extconf.DbExtConfig;
import io.jpom.system.init.InitDb;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
@ -83,6 +84,7 @@ import java.util.List;
@RequestMapping(value = "system")
@Feature(cls = ClassFeature.SYSTEM_CONFIG)
@SystemPermission
@Slf4j
public class SystemConfigController extends BaseServerController {
private final SystemParametersServer systemParametersServer;
@ -134,7 +136,7 @@ public class SystemConfigController extends BaseServerController {
ByteArrayResource resource = new ByteArrayResource(content.replace("\t", " ").getBytes(StandardCharsets.UTF_8));
yamlPropertySourceLoader.load("test", resource);
} catch (Exception e) {
DefaultSystemLog.getLog().warn("内容格式错误,请检查修正", e);
log.warn("内容格式错误,请检查修正", e);
return JsonMessage.getString(500, "内容格式错误,请检查修正:" + e.getMessage());
}
boolean restartBool = Convert.toBool(restart, false);

View File

@ -42,6 +42,7 @@ import io.jpom.service.system.SystemParametersServer;
import io.jpom.service.user.UserBindWorkspaceService;
import io.jpom.service.user.UserService;
import io.jpom.util.TwoFactorAuthUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
@ -61,6 +62,7 @@ import java.util.concurrent.TimeUnit;
*/
@RestController
@RequestMapping(value = "/user")
@Slf4j
public class UserBasicInfoController extends BaseServerController {
private static final TimedCache<String, Integer> CACHE = new TimedCache<>(TimeUnit.MINUTES.toMillis(30));
@ -144,7 +146,7 @@ public class UserBasicInfoController extends BaseServerController {
try {
EmailUtil.send(email, "Jpom 验证码", "验证码是:" + randomInt);
} catch (Exception e) {
DefaultSystemLog.getLog().error("发送失败", e);
log.error("发送失败", e);
return JsonMessage.getString(500, "发送邮件失败:" + e.getMessage());
}
CACHE.put(email, randomInt);

View File

@ -33,6 +33,7 @@ import io.jpom.model.data.UserBindWorkspaceModel;
import io.jpom.model.data.UserModel;
import io.jpom.service.user.UserBindWorkspaceService;
import io.jpom.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
@ -50,6 +51,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/user")
@Slf4j
public class UserInfoController extends BaseServerController {
private final UserService userService;
@ -84,7 +86,7 @@ public class UserInfoController extends BaseServerController {
getSession().invalidate();
return JsonMessage.getString(200, "修改密码成功!");
} catch (Exception e) {
DefaultSystemLog.getLog().error(e.getMessage(), e);
log.error(e.getMessage(), e);
return JsonMessage.getString(500, "系统异常:" + e.getMessage());
}
}

View File

@ -83,7 +83,7 @@ public class SshModel extends BaseWorkspaceModel {
/**
* 节点超时时间
*/
private Integer timeOut;
private Integer timeout;
public SshModel(String id) {
this.setId(id);
@ -127,11 +127,11 @@ public class SshModel extends BaseWorkspaceModel {
*
* @return 最小值 1 分钟
*/
public int timeOut() {
if (this.timeOut == null) {
public int timeout() {
if (this.timeout == null) {
return 5;
}
return Math.max(1, this.timeOut);
return Math.max(1, this.timeout);
}
public Charset getCharsetT() {

View File

@ -50,6 +50,7 @@ import io.jpom.service.monitor.MonitorService;
import io.jpom.service.node.NodeService;
import io.jpom.service.node.ProjectInfoCacheService;
import io.jpom.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.List;
@ -62,6 +63,7 @@ import java.util.stream.Collectors;
* @author bwcx_jzy
* @since 2021/12/14
*/
@Slf4j
public class MonitorItem implements Task {
@ -140,7 +142,7 @@ public class MonitorItem implements Task {
context = jsonMessage.toString();
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("监控 {} 节点异常 {}", nodeModel.getName(), e.getMessage());
log.error("监控 {} 节点异常 {}", nodeModel.getName(), e.getMessage());
//
title = StrUtil.format("【{}】节点的运行状态异常", nodeModel.getName());
context = ExceptionUtil.stacktraceToString(e);
@ -207,7 +209,7 @@ public class MonitorItem implements Task {
}
context = "重启结果:" + reJson;
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行重启操作", e);
log.error("执行重启操作", e);
title = StrUtil.format("【{}】节点的【{}】项目{}已经停止,重启操作异常", nodeModel.getName(), id, copyMsg);
context = ExceptionUtil.stacktraceToString(e);
}
@ -296,7 +298,7 @@ public class MonitorItem implements Task {
plugin.execute(webhook, map);
dbMonitorNotifyLogService.updateStatus(logId, true, null);
} catch (Exception e) {
DefaultSystemLog.getLog().error("WebHooks 调用错误", e);
log.error("WebHooks 调用错误", e);
dbMonitorNotifyLogService.updateStatus(logId, false, ExceptionUtil.stacktraceToString(e));
}
});
@ -361,7 +363,7 @@ public class MonitorItem implements Task {
NotifyUtil.send(notify, title, context);
dbMonitorNotifyLogService.updateStatus(logId, true, null);
} catch (Exception e) {
DefaultSystemLog.getLog().error("发送报警通知异常", e);
log.error("发送报警通知异常", e);
dbMonitorNotifyLogService.updateStatus(logId, false, ExceptionUtil.stacktraceToString(e));
}
});

View File

@ -43,6 +43,7 @@ import io.jpom.model.log.OutGivingLog;
import io.jpom.service.outgiving.DbOutGivingLogService;
import io.jpom.service.node.NodeService;
import io.jpom.service.outgiving.OutGivingServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import java.io.File;
@ -54,6 +55,7 @@ import java.util.stream.Collectors;
* @author bwcx_jzy
* @since 2021/12/10
*/
@Slf4j
public class OutGivingItemRun implements Callable<OutGivingNodeProject.Status> {
private final String outGivingId;
@ -107,7 +109,7 @@ public class OutGivingItemRun implements Callable<OutGivingNodeProject.Status> {
}
this.updateStatus(this.outGivingId, this.outGivingNodeProject, result, jsonMessage.toString());
} catch (Exception e) {
DefaultSystemLog.getLog().error(this.outGivingNodeProject.getNodeId() + " " + this.outGivingNodeProject.getProjectId() + " " + "分发异常保存", e);
log.error(this.outGivingNodeProject.getNodeId() + " " + this.outGivingNodeProject.getProjectId() + " " + "分发异常保存", e);
result = OutGivingNodeProject.Status.Fail;
this.updateStatus(this.outGivingId, this.outGivingNodeProject, result, "error:" + e.getMessage());
}

View File

@ -37,6 +37,7 @@ import io.jpom.model.enums.BuildReleaseMethod;
import io.jpom.model.enums.BuildStatus;
import io.jpom.service.IStatusRecover;
import io.jpom.service.h2db.BaseGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
@ -49,6 +50,7 @@ import java.util.List;
* @since 2021-08-10
**/
@Service
@Slf4j
public class BuildInfoService extends BaseGroupService<BuildInfoModel> implements ICron<BuildInfoModel>, IStatusRecover {
/**
@ -119,7 +121,7 @@ public class BuildInfoService extends BaseGroupService<BuildInfoModel> implement
CronUtils.remove(taskId);
return false;
}
DefaultSystemLog.getLog().debug("start build cron {} {} {}", id, buildInfoModel.getName(), autoBuildCron);
log.debug("start build cron {} {} {}", id, buildInfoModel.getName(), autoBuildCron);
CronUtils.upsert(taskId, autoBuildCron, new CronTask(id, autoBuildCron));
return true;
}

View File

@ -48,6 +48,7 @@ import io.jpom.service.monitor.MonitorUserOptService;
import io.jpom.service.system.WorkspaceService;
import io.jpom.service.user.UserService;
import io.jpom.system.init.OperateLogController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
@ -63,6 +64,7 @@ import java.util.stream.Collectors;
* @since 2019/7/20
*/
@Service
@Slf4j
public class DbUserOperateLogService extends BaseWorkspaceService<UserOperateLogV1> {
private final MonitorUserOptService monitorUserOptService;
@ -204,7 +206,7 @@ public class DbUserOperateLogService extends BaseWorkspaceService<UserOperateLog
try {
NotifyUtil.send(notify1, "用户操作报警", context);
} catch (Exception e) {
DefaultSystemLog.getLog().error("发送报警信息错误", e);
log.error("发送报警信息错误", e);
}
});
@ -217,7 +219,7 @@ public class DbUserOperateLogService extends BaseWorkspaceService<UserOperateLog
try {
NotifyUtil.send(notify1, "用户操作报警", context);
} catch (Exception e) {
DefaultSystemLog.getLog().error("发送报警信息错误", e);
log.error("发送报警信息错误", e);
}
});
}
@ -229,7 +231,7 @@ public class DbUserOperateLogService extends BaseWorkspaceService<UserOperateLog
try {
NotifyUtil.send(notify1, "用户操作报警", context);
} catch (Exception e) {
DefaultSystemLog.getLog().error("发送报警信息错误", e);
log.error("发送报警信息错误", e);
}
});
}
@ -249,7 +251,7 @@ public class DbUserOperateLogService extends BaseWorkspaceService<UserOperateLog
try {
this.checkMonitor(userOperateLogV1, cacheInfo);
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行操作监控错误", e);
log.error("执行操作监控错误", e);
}
});
}

View File

@ -45,6 +45,7 @@ import io.jpom.model.BaseUserModifyDbModel;
import io.jpom.model.PageResultDto;
import io.jpom.model.data.UserModel;
import io.jpom.system.extconf.DbExtConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
@ -62,6 +63,7 @@ import java.util.stream.Collectors;
* @author bwcx_jzy
* @since 2021/8/13
*/
@Slf4j
public abstract class BaseDbService<T extends BaseDbModel> extends BaseDbCommonService<T> {
public BaseDbService() {
@ -374,7 +376,7 @@ public abstract class BaseDbService<T extends BaseDbModel> extends BaseDbCommonS
entity.set(timeColumn, "< " + time);
int count = super.del(entity);
if (count > 0) {
DefaultSystemLog.getLog().debug("{} 清理了 {}条数据", super.getTableName(), count);
log.debug("{} 清理了 {}条数据", super.getTableName(), count);
}
});
}
@ -431,7 +433,7 @@ public abstract class BaseDbService<T extends BaseDbModel> extends BaseDbCommonS
} catch (java.lang.IllegalStateException illegalStateException) {
return 0L;
} catch (Exception e) {
DefaultSystemLog.getLog().error("查询数据错误", e);
log.error("查询数据错误", e);
return 0L;
}
if (pageResult.isEmpty()) {

View File

@ -44,6 +44,7 @@ import io.jpom.service.node.NodeService;
import io.jpom.service.system.WorkspaceService;
import io.jpom.system.AgentException;
import io.jpom.system.AuthorizeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
@ -57,6 +58,7 @@ import java.util.stream.Collectors;
* @author bwcx_jzy
* @since 2021/12/5
*/
@Slf4j
public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseWorkspaceService<T> {
protected final NodeService nodeService;
@ -94,7 +96,7 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseWorks
ThreadUtil.execute(() -> {
List<NodeModel> list = nodeService.list();
if (CollUtil.isEmpty(list)) {
DefaultSystemLog.getLog().debug("没有任何节点");
log.debug("没有任何节点");
return;
}
// 排序 避免项目被个节点绑定
@ -132,7 +134,7 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseWorks
public String syncExecuteNode(NodeModel nodeModel) {
String nodeModelName = nodeModel.getName();
if (!nodeModel.isOpenStatus()) {
DefaultSystemLog.getLog().debug("{} 节点未启用", nodeModelName);
log.debug("{} 节点未启用", nodeModelName);
return "节点未启用";
}
try {
@ -142,7 +144,7 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseWorks
entity.set("nodeId", nodeModel.getId());
int del = super.del(entity);
//
DefaultSystemLog.getLog().debug("{} 节点没有拉取到任何{}", nodeModelName, dataName);
log.debug("{} 节点没有拉取到任何{}", nodeModelName, dataName);
return "节点没有拉取到任何" + dataName;
}
// 查询现在存在的项目
@ -185,7 +187,7 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseWorks
CollUtil.size(cacheAll), dataName,
CollUtil.size(models), dataName,
CollUtil.size(strings));
DefaultSystemLog.getLog().debug(format);
log.debug(format);
return format;
} catch (Exception e) {
return this.checkException(e, nodeModelName);
@ -197,14 +199,14 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseWorks
protected String checkException(Exception e, String nodeModelName) {
if (e instanceof AgentException) {
AgentException agentException = (AgentException) e;
DefaultSystemLog.getLog().error("{} 同步失败 {}", nodeModelName, agentException.getMessage());
log.error("{} 同步失败 {}", nodeModelName, agentException.getMessage());
return "同步失败" + agentException.getMessage();
} else if (e instanceof AuthorizeException) {
AuthorizeException authorizeException = (AuthorizeException) e;
DefaultSystemLog.getLog().error("{} 同步失败 {}", nodeModelName, authorizeException.getMessage());
log.error("{} 同步失败 {}", nodeModelName, authorizeException.getMessage());
return "同步失败" + authorizeException.getMessage();
}
DefaultSystemLog.getLog().error("同步节点" + dataName + "失败:" + nodeModelName, e);
log.error("同步节点" + dataName + "失败:" + nodeModelName, e);
return "同步节点" + dataName + "失败" + e.getMessage();
}
@ -216,7 +218,7 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseWorks
public void syncNode(final NodeModel nodeModel, String id) {
String nodeModelName = nodeModel.getName();
if (!nodeModel.isOpenStatus()) {
DefaultSystemLog.getLog().debug("{} 节点未启用", nodeModelName);
log.debug("{} 节点未启用", nodeModelName);
return;
}
ThreadUtil.execute(() -> {

View File

@ -28,6 +28,7 @@ import io.jpom.cron.ICron;
import io.jpom.model.data.MonitorModel;
import io.jpom.monitor.MonitorItem;
import io.jpom.service.h2db.BaseWorkspaceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
@ -39,6 +40,7 @@ import java.util.List;
* @author Arno
*/
@Service
@Slf4j
public class MonitorService extends BaseWorkspaceService<MonitorModel> implements ICron<MonitorModel> {
@Override
@ -88,7 +90,7 @@ public class MonitorService extends BaseWorkspaceService<MonitorModel> implement
CronUtils.remove(taskId);
return false;
}
DefaultSystemLog.getLog().debug("start monitor cron {} {} {}", id, monitorModel.getName(), autoExecCron);
log.debug("start monitor cron {} {} {}", id, monitorModel.getName(), autoExecCron);
CronUtils.upsert(taskId, autoExecCron, new MonitorItem(id));
return true;
}

View File

@ -362,7 +362,7 @@ public class NodeService extends BaseGroupService<NodeModel> {
// where.setUrl(info.getUrl());
// int updateCount = super.update(super.dataBeanToEntity(update), super.dataBeanToEntity(where));
// if (updateCount > 1) {
// DefaultSystemLog.getLog().debug("update duplicate node {} {}", info.getUrl(), updateCount);
// log.debug("update duplicate node {} {}", info.getUrl(), updateCount);
// }
}

View File

@ -47,6 +47,7 @@ import io.jpom.model.data.UserModel;
import io.jpom.service.h2db.BaseWorkspaceService;
import io.jpom.service.node.ssh.SshService;
import io.jpom.service.system.WorkspaceEnvVarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@ -67,6 +68,7 @@ import java.util.stream.Collectors;
* @since : 2021/12/6 22:11
*/
@Service
@Slf4j
public class CommandService extends BaseWorkspaceService<CommandModel> implements ICron<CommandModel> {
private final SshService sshService;
@ -122,7 +124,7 @@ public class CommandService extends BaseWorkspaceService<CommandModel> implement
CronUtils.remove(taskId);
return false;
}
DefaultSystemLog.getLog().debug("start ssh command cron {} {} {}", id, buildInfoModel.getName(), autoExecCron);
log.debug("start ssh command cron {} {} {}", id, buildInfoModel.getName(), autoExecCron);
CronUtils.upsert(taskId, autoExecCron, new CommandService.CronTask(id));
return true;
}
@ -151,7 +153,7 @@ public class CommandService extends BaseWorkspaceService<CommandModel> implement
CommandModel commandModel = CommandService.this.getByKey(this.id);
CommandService.this.executeBatch(commandModel, commandModel.getDefParams(), commandModel.getSshIds(), 1);
} catch (Exception e) {
DefaultSystemLog.getLog().error("触发自动执行命令模版异常", e);
log.error("触发自动执行命令模版异常", e);
} finally {
BaseServerController.removeEmpty();
}
@ -226,7 +228,7 @@ public class CommandService extends BaseWorkspaceService<CommandModel> implement
try {
this.execute(commandModel, commandExecLogModel, sshModel, commandParamsLine);
} catch (Exception e) {
DefaultSystemLog.getLog().error("命令模版执行链接异常", e);
log.error("命令模版执行链接异常", e);
this.updateStatus(commandExecLogModel.getId(), CommandExecLogModel.Status.SESSION_ERROR);
}
});
@ -266,13 +268,13 @@ public class CommandService extends BaseWorkspaceService<CommandModel> implement
InputStream in = null;
try {
channel.connect((int) TimeUnit.SECONDS.toMillis(sshModel.timeOut()));
channel.connect((int) TimeUnit.SECONDS.toMillis(sshModel.timeout()));
in = channel.getInputStream();
IoUtil.readLines(in, charset, (LineHandler) line -> this.appendLine(outputStream, line));
// 更新状态
this.updateStatus(commandExecLogModel.getId(), CommandExecLogModel.Status.DONE);
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行命令错误", e);
log.error("执行命令错误", e);
// 更新状态
this.updateStatus(commandExecLogModel.getId(), CommandExecLogModel.Status.ERROR);
// 记录错误日志
@ -312,7 +314,7 @@ public class CommandService extends BaseWorkspaceService<CommandModel> implement
outputStream.write(LINE_BYTES);
outputStream.flush();
} catch (IOException e) {
DefaultSystemLog.getLog().warn("command log append line:{}", e.getMessage());
log.warn("command log append line:{}", e.getMessage());
}
}

View File

@ -105,7 +105,7 @@ public class NodeScriptExecuteLogServer extends BaseNodeService<ScriptExecuteLog
public Collection<String> syncExecuteNodeInc(NodeModel nodeModel) {
String nodeModelName = nodeModel.getName();
if (!nodeModel.isOpenStatus()) {
DefaultSystemLog.getLog().debug("{} 节点未启用", nodeModelName);
log.debug("{} 节点未启用", nodeModelName);
return null;
}
try {
@ -133,7 +133,7 @@ public class NodeScriptExecuteLogServer extends BaseNodeService<ScriptExecuteLog
"{} 节点拉取到 {} 个执行记录,更新 {} 个执行记录",
nodeModelName, CollUtil.size(jsonArray),
CollUtil.size(models));
DefaultSystemLog.getLog().debug(format);
log.debug(format);
return models.stream().map(BaseDbModel::getId).collect(Collectors.toList());
} catch (Exception e) {
this.checkException(e, nodeModelName);
@ -158,7 +158,7 @@ public class NodeScriptExecuteLogServer extends BaseNodeService<ScriptExecuteLog
}
return true;
} catch (Exception e) {
DefaultSystemLog.getLog().error("自动清除数据错误 {} {}", executeLogModel.getNodeId(), executeLogModel.getScriptName(), e);
log.error("自动清除数据错误 {} {}", executeLogModel.getNodeId(), executeLogModel.getScriptName(), e);
return false;
}
});

View File

@ -29,6 +29,7 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.*;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.extra.ftp.FtpConfig;
import cn.hutool.extra.ssh.ChannelType;
import cn.hutool.extra.ssh.JschRuntimeException;
import cn.hutool.extra.ssh.JschUtil;
@ -49,6 +50,7 @@ import org.springframework.util.Assert;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@ -89,10 +91,10 @@ public class SshService extends BaseWorkspaceService<SshModel> {
*/
public static Session getSessionByModel(SshModel sshModel) {
Session session = null;
int timeOut = (int) TimeUnit.SECONDS.toMillis(sshModel.timeOut());
int timeout = (int) TimeUnit.SECONDS.toMillis(sshModel.timeout());
SshModel.ConnectType connectType = sshModel.connectType();
if (connectType == SshModel.ConnectType.PASS) {
session = JschUtil.openSession(sshModel.getHost(), sshModel.getPort(), sshModel.getUser(), sshModel.getPassword(), timeOut);
session = JschUtil.openSession(sshModel.getHost(), sshModel.getPort(), sshModel.getUser(), sshModel.getPassword(), timeout);
} else if (connectType == SshModel.ConnectType.PUBKEY) {
File rsaFile = null;
@ -130,11 +132,11 @@ public class SshService extends BaseWorkspaceService<SshModel> {
Assert.state(FileUtil.isFile(rsaFile), "私钥文件不存在:" + FileUtil.getAbsolutePath(rsaFile));
session = JschUtil.createSession(sshModel.getHost(),
sshModel.getPort(), sshModel.getUser(), FileUtil.getAbsolutePath(rsaFile), sshModel.password());
try {
session.connect(timeOut);
} catch (JSchException e) {
throw new JschRuntimeException(e);
}
}
try {
session.connect(timeout);
} catch (JSchException e) {
throw new JschRuntimeException(e);
}
} else {
throw new IllegalArgumentException("不支持的模式");
@ -351,8 +353,9 @@ public class SshService extends BaseWorkspaceService<SshModel> {
try {
session = getSessionByModel(sshModel);
channel = (ChannelSftp) JschUtil.openChannel(session, ChannelType.SFTP);
Sftp sftp = new Sftp(channel, sshModel.getCharsetT());
sftp.syncUpload(desc, remotePath);
try (Sftp sftp = new Sftp(channel, sshModel.getCharsetT())) {
sftp.syncUpload(desc, remotePath);
}
//uploadDir(channel, remotePath, desc, sshModel.getCharsetT());
} finally {
JschUtil.close(channel);
@ -366,17 +369,17 @@ public class SshService extends BaseWorkspaceService<SshModel> {
* @param sshModel 实体
* @param remoteFile 远程文件
* @param save 文件对象
* @throws FileNotFoundException io
* @throws SftpException sftp
* @throws IOException io
* @throws SftpException sftp
*/
public void download(SshModel sshModel, String remoteFile, File save) throws FileNotFoundException, SftpException {
public void download(SshModel sshModel, String remoteFile, File save) throws IOException, SftpException {
Session session = null;
ChannelSftp channel = null;
OutputStream output = null;
try {
session = getSessionByModel(sshModel);
channel = (ChannelSftp) JschUtil.openChannel(session, ChannelType.SFTP);
output = new FileOutputStream(save);
output = Files.newOutputStream(save.toPath());
channel.get(remoteFile, output);
} finally {
IoUtil.close(output);

View File

@ -34,6 +34,7 @@ import io.jpom.model.script.ScriptExecuteLogModel;
import io.jpom.model.script.ScriptModel;
import io.jpom.service.h2db.BaseWorkspaceService;
import io.jpom.socket.ScriptProcessBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
@ -44,6 +45,7 @@ import java.util.List;
* @since 2022/1/19
*/
@Service
@Slf4j
public class ScriptServer extends BaseWorkspaceService<ScriptModel> implements ICron<ScriptModel> {
@Override
@ -91,7 +93,7 @@ public class ScriptServer extends BaseWorkspaceService<ScriptModel> implements I
CronUtils.remove(taskId);
return false;
}
DefaultSystemLog.getLog().debug("start script cron {} {} {}", id, scriptModel.getName(), autoExecCron);
log.debug("start script cron {} {} {}", id, scriptModel.getName(), autoExecCron);
CronUtils.upsert(taskId, autoExecCron, new CronTask(id));
return true;
}
@ -120,7 +122,7 @@ public class ScriptServer extends BaseWorkspaceService<ScriptModel> implements I
// 执行
ScriptProcessBuilder.create(scriptServerItem, nodeScriptExecLogModel.getId(), scriptServerItem.getDefArgs());
} catch (Exception e) {
DefaultSystemLog.getLog().error("触发自动执行命令模版异常", e);
log.error("触发自动执行命令模版异常", e);
} finally {
BaseServerController.removeEmpty();
}

View File

@ -45,6 +45,7 @@ import io.jpom.service.node.NodeService;
import io.jpom.system.AgentException;
import io.jpom.system.AuthorizeException;
import io.jpom.system.ServerExtConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Collection;
@ -61,6 +62,7 @@ import java.util.stream.Collectors;
* @since 2022/1/22
*/
@Service
@Slf4j
public class NodeStatService extends BaseWorkspaceService<NodeStatModel> implements IAsyncLoad, Runnable {
private final ServerExtConfigBean serverExtConfigBean;
@ -171,7 +173,7 @@ public class NodeStatService extends BaseWorkspaceService<NodeStatModel> impleme
this.save(modelList, 1, e.getMessage());
} catch (Exception e) {
this.save(modelList, 1, e.getMessage());
DefaultSystemLog.getLog().error("获取节点监控信息失败", e);
log.error("获取节点监控信息失败", e);
} finally {
BaseServerController.removeEmpty();
}

View File

@ -31,6 +31,7 @@ import io.jpom.model.data.WorkspaceModel;
import io.jpom.service.h2db.BaseDbService;
import io.jpom.service.h2db.TableName;
import io.jpom.service.node.NodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Set;
@ -40,6 +41,7 @@ import java.util.Set;
* @since 2021/12/3
*/
@Service
@Slf4j
public class WorkspaceService extends BaseDbService<WorkspaceModel> {
/**
@ -57,7 +59,7 @@ public class WorkspaceService extends BaseDbService<WorkspaceModel> {
defaultWorkspace.setDescription("系统默认的工作空间,不能删除");
super.insert(defaultWorkspace);
DefaultSystemLog.getLog().info("init created default workspace");
log.info("init created default workspace");
}
@ -75,7 +77,7 @@ public class WorkspaceService extends BaseDbService<WorkspaceModel> {
NodeService nodeService = SpringUtil.getBean(NodeService.class);
int execute = nodeService.execute(sql, Const.WORKSPACE_DEFAULT_ID);
if (execute > 0) {
DefaultSystemLog.getLog().info("convertNullWorkspaceId {} {}", tableName.value(), execute);
log.info("convertNullWorkspaceId {} {}", tableName.value(), execute);
}
}

View File

@ -32,6 +32,7 @@ import io.jpom.permission.Feature;
import io.jpom.permission.MethodFeature;
import io.jpom.system.init.OperateLogController;
import io.jpom.util.SocketSessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketSession;
@ -43,6 +44,7 @@ import java.util.Map;
* @author bwcx_jzy
* @since 2019/8/9
*/
@Slf4j
public abstract class BaseHandler extends TextWebSocketHandler {
@Override
@ -78,7 +80,7 @@ public abstract class BaseHandler extends TextWebSocketHandler {
@Override
public void handleTransportError(WebSocketSession session, Throwable exception) {
DefaultSystemLog.getLog().error(session.getId() + "socket 异常", exception);
log.error(session.getId() + "socket 异常", exception);
destroy(session);
}
@ -98,7 +100,7 @@ public abstract class BaseHandler extends TextWebSocketHandler {
try {
SocketSessionUtil.send(session, msg);
} catch (Exception e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
}
}
@ -139,7 +141,7 @@ public abstract class BaseHandler extends TextWebSocketHandler {
OperateLogController operateLogController = SpringUtil.getBean(OperateLogController.class);
operateLogController.log(userInfo, JSONObject.toJSONString(attributes), cacheInfo);
} catch (Exception e) {
DefaultSystemLog.getLog().error("记录操作日志异常", e);
log.error("记录操作日志异常", e);
} finally {
if (proxySession != null) {
attributes.put("proxySession", proxySession);

View File

@ -29,6 +29,7 @@ import cn.jiangzeyin.common.DefaultSystemLog;
import cn.jiangzeyin.common.spring.SpringUtil;
import com.alibaba.fastjson.JSONObject;
import io.jpom.system.init.OperateLogController;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import org.springframework.web.socket.TextMessage;
@ -46,6 +47,7 @@ import java.util.concurrent.TimeUnit;
* @author jiangzeyin
* @since 2019/4/16
*/
@Slf4j
public class ProxySession extends WebSocketClient {
private final WebSocketSession session;
private final OperateLogController logController;
@ -85,7 +87,7 @@ public class ProxySession extends WebSocketClient {
try {
session.sendMessage(new TextMessage(message));
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
}
try {
JSONObject jsonObject = JSONObject.parseObject(message);
@ -102,7 +104,7 @@ public class ProxySession extends WebSocketClient {
try {
session.close();
} catch (IOException e) {
DefaultSystemLog.getLog().error("关闭错误", e);
log.error("关闭错误", e);
}
}
@ -113,7 +115,7 @@ public class ProxySession extends WebSocketClient {
// SocketSessionUtil.send(session, );
} catch (IOException ignored) {
}
DefaultSystemLog.getLog().error("发生错误", ex);
log.error("发生错误", ex);
}
@Override
@ -121,7 +123,7 @@ public class ProxySession extends WebSocketClient {
try {
super.send(text);
} catch (Exception e) {
DefaultSystemLog.getLog().error("转发消息失败", e);
log.error("转发消息失败", e);
}
}
}

View File

@ -40,6 +40,7 @@ import io.jpom.service.system.WorkspaceEnvVarService;
import io.jpom.system.ExtConfigBean;
import io.jpom.util.CommandUtil;
import io.jpom.util.SocketSessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.socket.WebSocketSession;
import java.io.File;
@ -53,6 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @author jiangzeyin
* @since 2022/1/19
*/
@Slf4j
public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
/**
* 执行中的缓存
@ -78,7 +80,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
List<String> command = StrUtil.splitTrim(args, StrUtil.SPACE);
command.add(0, script);
command.add(0, CommandUtil.EXECUTE_PREFIX);
DefaultSystemLog.getLog().debug(CollUtil.join(command, StrUtil.SPACE));
log.debug(CollUtil.join(command, StrUtil.SPACE));
processBuilder.redirectErrorStream(true);
processBuilder.command(command);
Map<String, String> environment = processBuilder.environment();
@ -119,7 +121,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
try {
SocketSessionUtil.send(session, line);
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
}
});
}
@ -178,7 +180,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
this.end(jsonObject.toString());
this.handle("execute done:" + waitFor + " time:" + DateUtil.now());
} catch (Exception e) {
DefaultSystemLog.getLog().error("执行异常", e);
log.error("执行异常", e);
this.end("执行异常:" + e.getMessage());
} finally {
this.close();
@ -198,7 +200,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
try {
SocketSessionUtil.send(session, msg);
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
}
iterator.remove();
}
@ -220,7 +222,7 @@ public class ScriptProcessBuilder extends BaseRunScript implements Runnable {
try {
SocketSessionUtil.send(session, line);
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
iterator.remove();
}
}

View File

@ -41,6 +41,7 @@ import io.jpom.service.h2db.BaseWorkspaceService;
import io.jpom.service.node.NodeService;
import io.jpom.service.user.UserBindWorkspaceService;
import io.jpom.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
@ -57,6 +58,7 @@ import java.util.Map;
* @author jiangzeyin
* @since 2019/4/19
*/
@Slf4j
public class ServerWebSocketInterceptor implements HandshakeInterceptor {
private boolean checkNode(HttpServletRequest httpServletRequest, Map<String, Object> attributes, UserModel userModel) {
@ -79,7 +81,7 @@ public class ServerWebSocketInterceptor implements HandshakeInterceptor {
String type = httpServletRequest.getParameter("type");
HandlerType handlerType = EnumUtil.fromString(HandlerType.class, type, null);
if (handlerType == null) {
DefaultSystemLog.getLog().warn("传入的类型错误:{}", type);
log.warn("传入的类型错误:{}", type);
}
return handlerType;
}
@ -225,7 +227,7 @@ public class ServerWebSocketInterceptor implements HandshakeInterceptor {
@Override
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) {
if (exception != null) {
DefaultSystemLog.getLog().error("afterHandshake", exception);
log.error("afterHandshake", exception);
}
}
}

View File

@ -25,6 +25,7 @@ package io.jpom.socket;
import cn.hutool.core.io.FileUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import io.jpom.util.BaseFileTailWatcher;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.socket.WebSocketSession;
import java.io.File;
@ -39,6 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @author jiangzeyin
* @since 2019/07/21
*/
@Slf4j
public class ServiceFileTailWatcher<T> extends BaseFileTailWatcher<T> {
private static final ConcurrentHashMap<File, ServiceFileTailWatcher<WebSocketSession>> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>();
@ -65,7 +67,7 @@ public class ServiceFileTailWatcher<T> extends BaseFileTailWatcher<T> {
try {
return new ServiceFileTailWatcher<>(file);
} catch (Exception e) {
DefaultSystemLog.getLog().error("创建文件监听失败", e);
log.error("创建文件监听失败", e);
return null;
}
});

View File

@ -30,6 +30,7 @@ import com.alibaba.fastjson.JSONObject;
import io.jpom.model.WebSocketMessageModel;
import io.jpom.model.data.NodeModel;
import io.jpom.system.init.OperateLogController;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import org.springframework.web.socket.TextMessage;
@ -47,6 +48,7 @@ import java.util.concurrent.TimeUnit;
*
* @author lf
*/
@Slf4j
public class NodeClient extends WebSocketClient {
private final WebSocketSession session;
private final OperateLogController logController;
@ -103,7 +105,7 @@ public class NodeClient extends WebSocketClient {
session.sendMessage(new TextMessage(message));
}
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败", e);
log.error("发送消息失败", e);
}
try {
JSONObject jsonObject = JSONObject.parseObject(message);
@ -131,7 +133,7 @@ public class NodeClient extends WebSocketClient {
try {
super.close();
} catch (Exception e) {
DefaultSystemLog.getLog().error("关闭异常", e);
log.error("关闭异常", e);
}
}
@ -142,6 +144,6 @@ public class NodeClient extends WebSocketClient {
@Override
public void onError(Exception e) {
DefaultSystemLog.getLog().error("发生异常", e);
log.error("发生异常", e);
}
}

View File

@ -25,6 +25,7 @@ package io.jpom.socket.handler;
import cn.hutool.core.util.StrUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import io.jpom.socket.BaseHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.socket.BinaryMessage;
import org.springframework.web.socket.WebSocketSession;
@ -34,6 +35,7 @@ import java.io.IOException;
* @author bwcx_jzy
* @since 2022/2/10
*/
@Slf4j
public abstract class BaseTerminalHandler extends BaseHandler {
protected void sendBinary(WebSocketSession session, String msg) {
@ -42,7 +44,7 @@ public abstract class BaseTerminalHandler extends BaseHandler {
}
if (!session.isOpen()) {
// 会话关闭不能发送消息 @author jzy 21-08-04
DefaultSystemLog.getLog().warn("回话已经关闭啦,不能发送消息:{}", msg);
log.warn("回话已经关闭啦,不能发送消息:{}", msg);
return;
}
synchronized (session.getId()) {
@ -50,7 +52,7 @@ public abstract class BaseTerminalHandler extends BaseHandler {
try {
session.sendMessage(byteBuffer);
} catch (IOException e) {
DefaultSystemLog.getLog().error("发送消息失败:" + msg, e);
log.error("发送消息失败:" + msg, e);
}
}
}

View File

@ -71,7 +71,7 @@ public class DockerCliHandler extends BaseTerminalHandler {
handlerItem.startRead();
} catch (Exception e) {
// 输出超时日志 @author jzy
DefaultSystemLog.getLog().error("docker 控制台连接超时", e);
log.error("docker 控制台连接超时", e);
sendBinary(session, "docker 控制台连接超时");
this.destroy(session);
return;
@ -108,7 +108,7 @@ public class DockerCliHandler extends BaseTerminalHandler {
this.sendCommand(handlerItem, payload);
} catch (Exception e) {
sendBinary(session, "Failure:" + e.getMessage());
DefaultSystemLog.getLog().error("执行命令异常", e);
log.error("执行命令异常", e);
}
}

View File

@ -51,6 +51,7 @@ import io.jpom.service.system.SystemParametersServer;
import io.jpom.socket.BaseProxyHandler;
import io.jpom.socket.ConsoleCommandOp;
import io.jpom.socket.client.NodeClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.socket.WebSocketSession;
import java.io.File;
@ -70,6 +71,7 @@ import java.util.concurrent.ConcurrentMap;
*/
@SystemPermission(superUser = true)
@Feature(cls = ClassFeature.UPGRADE_NODE_LIST, method = MethodFeature.EXECUTE)
@Slf4j
public class NodeUpdateHandler extends BaseProxyHandler {
private final ConcurrentMap<String, NodeClient> clientMap = new ConcurrentHashMap<>();
@ -121,7 +123,7 @@ public class NodeUpdateHandler extends BaseProxyHandler {
NodeClient client = new NodeClient(url, model, session);
clientMap.put(model.getId(), client);
} catch (Exception e) {
DefaultSystemLog.getLog().error("创建插件端连接失败", e);
log.error("创建插件端连接失败", e);
}
});
}
@ -207,7 +209,7 @@ public class NodeUpdateHandler extends BaseProxyHandler {
ThreadUtil.execute(() -> this.updateNodeItem(ids.getString(finalI), session, agentFileModel, http));
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("升级失败", e);
log.error("升级失败", e);
}
}
@ -236,7 +238,7 @@ public class NodeUpdateHandler extends BaseProxyHandler {
}
this.sendMsg(callbackRestartMessage.setData("重连失败"), session);
} catch (Exception e) {
DefaultSystemLog.getLog().error("升级后重连插件端失败:" + id, e);
log.error("升级后重连插件端失败:" + id, e);
this.sendMsg(callbackRestartMessage.setData("重连插件端失败"), session);
}
}
@ -277,7 +279,7 @@ public class NodeUpdateHandler extends BaseProxyHandler {
}
this.sendMsg(restartMessage.setData("重连失败"), session);
} catch (Exception e) {
DefaultSystemLog.getLog().error("升级后重连插件端失败:" + id, e);
log.error("升级后重连插件端失败:" + id, e);
this.sendMsg(restartMessage.setData("重连插件端失败"), session);
}
}
@ -304,7 +306,7 @@ public class NodeUpdateHandler extends BaseProxyHandler {
this.onError(session, "节点连接丢失");
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("升级失败:" + id, e);
log.error("升级失败:" + id, e);
this.onError(session, "节点升级失败:" + e.getMessage());
}
}

View File

@ -44,6 +44,7 @@ import io.jpom.permission.MethodFeature;
import io.jpom.service.dblog.SshTerminalExecuteLogService;
import io.jpom.service.node.ssh.SshService;
import io.jpom.service.user.UserBindWorkspaceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
@ -64,6 +65,7 @@ import java.util.concurrent.TimeUnit;
* @since 2019/8/9
*/
@Feature(cls = ClassFeature.SSH_TERMINAL, method = MethodFeature.EXECUTE)
@Slf4j
public class SshHandler extends BaseTerminalHandler {
private static final ConcurrentHashMap<String, HandlerItem> HANDLER_ITEM_CONCURRENT_HASH_MAP = new ConcurrentHashMap<>();
@ -92,7 +94,7 @@ public class SshHandler extends BaseTerminalHandler {
handlerItem.startRead();
} catch (Exception e) {
// 输出超时日志 @author jzy
DefaultSystemLog.getLog().error("ssh 控制台连接超时", e);
log.error("ssh 控制台连接超时", e);
sendBinary(session, "ssh 控制台连接超时");
this.destroy(session);
return;
@ -111,17 +113,19 @@ public class SshHandler extends BaseTerminalHandler {
return;
}
String payload = message.getPayload();
if (JSONValidator.from(payload).getType() == JSONValidator.Type.Object) {
JSONObject jsonObject = JSONObject.parseObject(payload);
String data = jsonObject.getString("data");
if (StrUtil.equals(data, "jpom-heart")) {
// 心跳消息不转发
return;
}
if (StrUtil.equals(data, "resize")) {
// 缓存区大小
handlerItem.resize(jsonObject);
return;
try (JSONValidator from = JSONValidator.from(payload)) {
if (from.getType() == JSONValidator.Type.Object) {
JSONObject jsonObject = JSONObject.parseObject(payload);
String data = jsonObject.getString("data");
if (StrUtil.equals(data, "jpom-heart")) {
// 心跳消息不转发
return;
}
if (StrUtil.equals(data, "resize")) {
// 缓存区大小
handlerItem.resize(jsonObject);
return;
}
}
}
init();
@ -134,7 +138,7 @@ public class SshHandler extends BaseTerminalHandler {
this.sendCommand(handlerItem, payload, userInfo, sshCommandNotLimited);
} catch (Exception e) {
sendBinary(session, "Failure:" + e.getMessage());
DefaultSystemLog.getLog().error("执行命令异常", e);
log.error("执行命令异常", e);
}
}
@ -194,7 +198,7 @@ public class SshHandler extends BaseTerminalHandler {
}
void startRead() throws JSchException {
this.channel.connect((int) TimeUnit.SECONDS.toMillis(sshItem.timeOut()));
this.channel.connect((int) TimeUnit.SECONDS.toMillis(sshItem.timeout()));
ThreadUtil.execute(this);
}
@ -273,7 +277,7 @@ public class SshHandler extends BaseTerminalHandler {
if (!this.openSession.isConnected()) {
return;
}
DefaultSystemLog.getLog().error("读取错误", e);
log.error("读取错误", e);
SshHandler.this.destroy(this.session);
}
}

View File

@ -37,6 +37,7 @@ import io.jpom.socket.ProxySession;
import io.jpom.socket.ServiceFileTailWatcher;
import io.jpom.system.WebAopLog;
import io.jpom.util.SocketSessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.socket.WebSocketSession;
import java.io.File;
@ -50,6 +51,7 @@ import java.util.Map;
* @since 2019/4/24
*/
@Feature(cls = ClassFeature.TOMCAT, method = MethodFeature.EXECUTE)
@Slf4j
public class TomcatHandler extends BaseProxyHandler {
public TomcatHandler() {
@ -87,7 +89,7 @@ public class TomcatHandler extends BaseProxyHandler {
ServiceFileTailWatcher.addWatcher(file, session);
attributes.put("nowFile", file);
} catch (Exception io) {
DefaultSystemLog.getLog().error("监听日志变化", io);
log.error("监听日志变化", io);
SocketSessionUtil.send(session, io.getMessage());
}
}

View File

@ -42,6 +42,7 @@ import io.jpom.system.ConfigBean;
import io.jpom.system.ServerConfigBean;
import io.jpom.util.JsonFileUtil;
import io.jpom.util.JvmUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
@ -52,6 +53,7 @@ import java.io.File;
* @since 2019/4/18
*/
@PreLoadClass
@Slf4j
public class AutoImportLocalNode {
private static NodeService nodeService;
@ -84,7 +86,7 @@ public class AutoImportLocalNode {
}
findPid(mainClassPid.toString());
} catch (Exception e) {
DefaultSystemLog.getLog().error("自动添加本机节点错误", e);
log.error("自动添加本机节点错误", e);
}
}

View File

@ -29,6 +29,7 @@ import cn.jiangzeyin.common.PreLoadMethod;
import io.jpom.system.JpomRuntimeException;
import io.jpom.system.ServerExtConfigBean;
import io.jpom.util.CheckPassword;
import lombok.extern.slf4j.Slf4j;
/**
* 验证token 合法性
@ -37,6 +38,7 @@ import io.jpom.util.CheckPassword;
* @since 2019/8/5
*/
@PreLoadClass
@Slf4j
public class CheckAuthorizeToken {
@PreLoadMethod
@ -46,12 +48,12 @@ public class CheckAuthorizeToken {
return;
}
if (authorizeToken.length() < 6) {
DefaultSystemLog.getLog().error("配置的授权token长度小于六位不生效", new JpomRuntimeException("配置的授权token长度小于六位不生效"));
log.error("配置的授权token长度小于六位不生效", new JpomRuntimeException("配置的授权token长度小于六位不生效"));
System.exit(-1);
}
int strength = CheckPassword.checkPasswordStrength(authorizeToken);
if (strength != 2) {
DefaultSystemLog.getLog().error("配置的授权token 需要包含数字,字母,符号的组合", new JpomRuntimeException("配置的授权token 需要包含数字,字母,符号的组合"));
log.error("配置的授权token 需要包含数字,字母,符号的组合", new JpomRuntimeException("配置的授权token 需要包含数字,字母,符号的组合"));
System.exit(-1);
}
}

View File

@ -42,6 +42,7 @@ import io.jpom.service.node.NodeService;
import io.jpom.service.node.script.NodeScriptExecuteLogServer;
import io.jpom.service.node.script.NodeScriptServer;
import io.jpom.system.ConfigBean;
import lombok.extern.slf4j.Slf4j;
import java.util.Collection;
import java.util.List;
@ -54,6 +55,7 @@ import java.util.Map;
* @since 2019/7/14
*/
@PreLoadClass(value = Integer.MAX_VALUE)
@Slf4j
public class CheckMonitor {
@PreLoadMethod
@ -71,7 +73,7 @@ public class CheckMonitor {
//
RemoteVersion.loadRemoteInfo();
} catch (Exception e) {
DefaultSystemLog.getLog().error("系统调度执行出现错误", e);
log.error("系统调度执行出现错误", e);
}
});
// 拉取 脚本模版日志
@ -110,10 +112,10 @@ public class CheckMonitor {
jsonObject.put("ids", strings);
JsonMessage<Object> jsonMessage = NodeForward.requestBody(nodeModel, NodeUrl.SCRIPT_DEL_EXEC_LOG, null, jsonObject);
if (jsonMessage.getCode() != HttpStatus.HTTP_OK) {
DefaultSystemLog.getLog().error("删除脚本模版执行数据错误:{}", jsonMessage);
log.error("删除脚本模版执行数据错误:{}", jsonMessage);
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("同步脚本异常", e);
log.error("同步脚本异常", e);
}
}
@ -130,7 +132,7 @@ public class CheckMonitor {
statusRecoverMap.forEach((name, iCron) -> {
int count = iCron.statusRecover();
if (count > 0) {
DefaultSystemLog.getLog().debug("{} Recover bad data {}", name, count);
log.debug("{} Recover bad data {}", name, count);
}
});
//

View File

@ -144,7 +144,7 @@ public class InitDb implements DisposableBean, InitializingBean {
}
sqlFileNow = resource.getFilename();
int rows = Db.use(dsFactory.getDataSource()).execute(sql);
DefaultSystemLog.getLog().info("exec init SQL file: {} complete, and affected rows is: {}", sqlFileNow, rows);
log.info("exec init SQL file: {} complete, and affected rows is: {}", sqlFileNow, rows);
executeSqlLog.add(sha1);
} catch (IOException ignored) {
}
@ -153,7 +153,7 @@ public class InitDb implements DisposableBean, InitializingBean {
GlobalDSFactory.set(dsFactory);
//
} catch (Exception e) {
DefaultSystemLog.getLog().error("初始化数据库失败 {}", sqlFileNow, e);
log.error("初始化数据库失败 {}", sqlFileNow, e);
System.exit(0);
return;
}

View File

@ -39,6 +39,7 @@ import io.jpom.service.h2db.TableName;
import io.jpom.system.ConfigBean;
import io.jpom.system.ServerConfigBean;
import io.jpom.util.JsonFileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import java.io.File;
@ -57,6 +58,7 @@ import java.util.stream.Stream;
* @author Hotstrip
* @since 2021-08-02
*/
@Slf4j
public class LoadBuildJsonToDB {
private LoadBuildJsonToDB() {
@ -85,7 +87,7 @@ public class LoadBuildJsonToDB {
// 判断 list 是否为空
if (null == list) {
if (!FileUtil.exist(FileUtil.file(backupOldData, ServerConfigBean.BUILD))) {
//DefaultSystemLog.getLog().warn("There is no any data, the build.json file maybe no content or file is not exist...");
//log.warn("There is no any data, the build.json file maybe no content or file is not exist...");
}
return;
}
@ -93,7 +95,7 @@ public class LoadBuildJsonToDB {
initSql(list);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
}
/**
@ -120,7 +122,7 @@ public class LoadBuildJsonToDB {
// 遍历对象集合
list.forEach(buildModelVo -> {
DefaultSystemLog.getLog().debug("buildModelVo: {}", JSON.toJSONString(buildModelVo));
log.debug("buildModelVo: {}", JSON.toJSONString(buildModelVo));
// 拿到构造 SQL 的参数
String gitUrl = buildModelVo.getString("gitUrl");
@ -171,9 +173,9 @@ public class LoadBuildJsonToDB {
try {
rows = Db.use(dsFactory.getDataSource()).execute(sql);
} catch (SQLException e) {
DefaultSystemLog.getLog().warn("exec SQL: {} failed", sql, e);
log.warn("exec SQL: {} failed", sql, e);
}
DefaultSystemLog.getLog().info("exec SQL: {} complete, and affected rows is: {}", sql, rows);
log.info("exec SQL: {} complete, and affected rows is: {}", sql, rows);
}
/**
@ -243,7 +245,7 @@ public class LoadBuildJsonToDB {
*/
private List<JSONObject> readBuildJsonFileToList(File file) {
if (!file.exists()) {
DefaultSystemLog.getLog().debug("there is no build.json file...");
log.debug("there is no build.json file...");
return null;
}
try {
@ -254,7 +256,7 @@ public class LoadBuildJsonToDB {
.flatMap((Function<Object, Stream<JSONObject>>) o -> Stream.of((JSONObject) o))
.collect(Collectors.toList());
} catch (FileNotFoundException e) {
DefaultSystemLog.getLog().error("read build.json file failed...caused: {}...message: {}", e.getCause(), e.getMessage());
log.error("read build.json file failed...caused: {}...message: {}", e.getCause(), e.getMessage());
}
return null;
}

View File

@ -47,6 +47,7 @@ import io.jpom.service.user.UserService;
import io.jpom.system.ConfigBean;
import io.jpom.system.ServerConfigBean;
import io.jpom.util.JsonFileUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.List;
@ -58,6 +59,7 @@ import java.util.stream.Collectors;
* @author bwcx_jzy
* @since 2021/12/2
*/
@Slf4j
public class LoadJsonConfigToDb {
private LoadJsonConfigToDb() {
@ -91,9 +93,9 @@ public class LoadJsonConfigToDb {
parametersServer.upsert(SystemIpConfigModel.ID, systemIpConfigModel, SystemIpConfigModel.ID);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load ip config error ", e);
log.error("load ip config error ", e);
}
}
@ -114,9 +116,9 @@ public class LoadJsonConfigToDb {
parametersServer.upsert(MailAccountModel.ID, mailAccountModel, MailAccountModel.ID);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load mail config error ", e);
log.error("load mail config error ", e);
}
}
@ -138,9 +140,9 @@ public class LoadJsonConfigToDb {
parametersServer.upsert(id, serverWhitelist, id);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load mail config error ", e);
log.error("load mail config error ", e);
}
}
@ -172,9 +174,9 @@ public class LoadJsonConfigToDb {
userService.insert(userModels);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load user info error ", e);
log.error("load user info error ", e);
}
}
@ -201,9 +203,9 @@ public class LoadJsonConfigToDb {
nodeService.insert(nodeModels);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load node error ", e);
log.error("load node error ", e);
}
}
@ -225,9 +227,9 @@ public class LoadJsonConfigToDb {
sshService.insert(sshModels);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load ssh error ", e);
log.error("load ssh error ", e);
}
}
@ -250,9 +252,9 @@ public class LoadJsonConfigToDb {
monitorService.insert(monitorModels);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load monitor error ", e);
log.error("load monitor error ", e);
}
}
@ -276,9 +278,9 @@ public class LoadJsonConfigToDb {
outGivingServer.insert(outGivingModels);
// json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
log.info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load OUTGIVING error ", e);
log.error("load OUTGIVING error ", e);
}
}

View File

@ -49,6 +49,7 @@ import io.jpom.service.dblog.DbUserOperateLogService;
import io.jpom.system.AopLogInterface;
import io.jpom.system.WebAopLog;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
@ -70,6 +71,7 @@ import java.util.Set;
* @since 2019/4/19
*/
@PreLoadClass
@Slf4j
public class OperateLogController implements AopLogInterface {
private static final ThreadLocal<CacheInfo> CACHE_INFO_THREAD_LOCAL = new ThreadLocal<>();
@ -88,14 +90,14 @@ public class OperateLogController implements AopLogInterface {
Class<?> declaringClass = method.getDeclaringClass();
MethodFeature methodFeature = feature.method();
if (methodFeature == MethodFeature.NULL) {
DefaultSystemLog.getLog().error("权限分发配置错误:{} {}", declaringClass, method.getName());
log.error("权限分发配置错误:{} {}", declaringClass, method.getName());
return null;
}
ClassFeature classFeature = feature.cls();
if (classFeature == ClassFeature.NULL) {
Feature feature1 = declaringClass.getAnnotation(Feature.class);
if (feature1 == null || feature1.cls() == ClassFeature.NULL) {
DefaultSystemLog.getLog().error("权限分发配置错误:{} {} class not find", declaringClass, method.getName());
log.error("权限分发配置错误:{} {} class not find", declaringClass, method.getName());
return null;
}
classFeature = feature1.cls();

Some files were not shown because too many files have changed in this diff Show More