🔨 执行日志.

This commit is contained in:
lijiahang
2024-03-19 17:48:48 +08:00
parent f8ea51eb8c
commit 29e3565af9
14 changed files with 479 additions and 81 deletions

View File

@@ -8,7 +8,7 @@ Authorization: {{token}}
"timeout": 10,
"command": "echo 这是日志@{{ hostAddress }}\nsleep 1\necho @{{ hostName }}",
"parameterSchema": "[]",
"hostIdList": [1,7]
"hostIdList": [1]
}

View File

@@ -77,7 +77,7 @@ public class ExecController {
}
@PostMapping("/tail-log")
@Operation(summary = "查看批量执行日志")
@Operation(summary = "查看执行日志")
@PreAuthorize("@ss.hasAnyPermission('asset:exec:exec-command', 'asset:exec-log:query')")
public String getExecLogTailToken(@Validated @RequestBody ExecLogTailRequest request) {
return execService.getExecLogTailToken(request);
@@ -85,9 +85,9 @@ public class ExecController {
@OperatorLog(ExecOperatorType.DOWNLOAD_HOST_LOG)
@GetMapping("/download-log")
@Operation(summary = "下载执行日志文件")
@Operation(summary = "下载执行日志")
@PreAuthorize("@ss.hasAnyPermission('asset:exec:exec-command', 'asset:exec-log:query')")
public void downloadLogFile(@RequestParam("id") Long id, HttpServletResponse response) {
public void downloadExecLogFile(@RequestParam("id") Long id, HttpServletResponse response) {
execService.downloadLogFile(id, response);
}

View File

@@ -26,6 +26,9 @@ public class ExecCommandVO implements Serializable {
@Schema(description = "id")
private Long id;
@Schema(description = "执行状态")
private String status;
@Schema(description = "主机 id 映射")
private List<ExecCommandHostVO> hosts;

View File

@@ -152,6 +152,8 @@ public class ExecCommandHandler implements IExecCommandHandler {
log.info("ExecCommandHandler.updateStatus finish id: {}, effect: {}", id, effect);
}
// TODO timeout
@Override
public void write(String msg) {
this.executor.write(msg);

View File

@@ -167,6 +167,7 @@ public class ExecServiceImpl implements ExecService {
.collect(Collectors.toList());
return ExecCommandVO.builder()
.id(execId)
.status(execLog.getStatus())
.hosts(hostResult)
.build();
}