feat: 完善本地MCP与扩展市场能力
This commit is contained in:
@@ -140,7 +140,16 @@ public class McpDeployTaskServiceImpl extends AbstractDeployTaskService implemen
|
||||
deployStatus = new McpDeployStatusResponse();
|
||||
deployStatus.setStatus(McpDeployStatusEnum.Ready);
|
||||
} else {
|
||||
deployStatus = mcpDeployRpcService.deploy(String.valueOf(id), serverConfig, McpPersistentTypeEnum.OneShot);
|
||||
try {
|
||||
deployStatus = mcpDeployRpcService.deploy(String.valueOf(id), serverConfig, McpPersistentTypeEnum.OneShot);
|
||||
} catch (Exception e) {
|
||||
log.warn("MCP service [{}] deploy request failed", mcpName, e);
|
||||
if (scheduleTask.getExecTimes() + 1 >= scheduleTask.getMaxExecTimes()) {
|
||||
markDeployFailed(userDto, id, mcpName, e.getMessage());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (deployStatus.getStatus() == McpDeployStatusEnum.Ready) {
|
||||
try {
|
||||
@@ -161,15 +170,7 @@ public class McpDeployTaskServiceImpl extends AbstractDeployTaskService implemen
|
||||
}
|
||||
}
|
||||
if (deployStatus.getStatus() == McpDeployStatusEnum.Error) {
|
||||
McpConfig mcpConfig = new McpConfig();
|
||||
mcpConfig.setId(id);
|
||||
mcpConfig.setDeployStatus(DeployStatusEnum.DeployFailed);
|
||||
mcpConfigDomainService.update(mcpConfig);
|
||||
notifyMessageApplicationService.sendNotifyMessage(SendNotifyMessageDto.builder()
|
||||
.scope(NotifyMessage.MessageScope.System)
|
||||
.content(I18nUtil.systemMessage(userDto.getLangMap(), "Backend.Mcp.Deploy.Failed", mcpName, deployStatus.getMessage()))
|
||||
.userIds(List.of(userId))
|
||||
.build());
|
||||
markDeployFailed(userDto, id, mcpName, deployStatus.getMessage());
|
||||
return true;
|
||||
}
|
||||
checkAndSendFailedNotifyMessage(userDto, id, mcpName, scheduleTask);
|
||||
@@ -178,10 +179,7 @@ public class McpDeployTaskServiceImpl extends AbstractDeployTaskService implemen
|
||||
|
||||
private void checkAndSendFailedNotifyMessage(UserDto userDto, Long id, String mcpName, ScheduleTaskDto scheduleTask) {
|
||||
if (scheduleTask.getExecTimes() + 1 >= scheduleTask.getMaxExecTimes()) {
|
||||
McpConfig mcpConfig = new McpConfig();
|
||||
mcpConfig.setId(id);
|
||||
mcpConfig.setDeployStatus(DeployStatusEnum.DeployFailed);
|
||||
mcpConfigDomainService.update(mcpConfig);
|
||||
updateDeployFailed(id);
|
||||
notifyMessageApplicationService.sendNotifyMessage(SendNotifyMessageDto.builder()
|
||||
.scope(NotifyMessage.MessageScope.System)
|
||||
.content(I18nUtil.systemMessage(userDto.getLangMap(), "Backend.Mcp.Deploy.Timeout", mcpName))
|
||||
@@ -189,4 +187,20 @@ public class McpDeployTaskServiceImpl extends AbstractDeployTaskService implemen
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
private void markDeployFailed(UserDto userDto, Long id, String mcpName, String message) {
|
||||
updateDeployFailed(id);
|
||||
notifyMessageApplicationService.sendNotifyMessage(SendNotifyMessageDto.builder()
|
||||
.scope(NotifyMessage.MessageScope.System)
|
||||
.content(I18nUtil.systemMessage(userDto.getLangMap(), "Backend.Mcp.Deploy.Failed", mcpName, message))
|
||||
.userIds(List.of(userDto.getId()))
|
||||
.build());
|
||||
}
|
||||
|
||||
private void updateDeployFailed(Long id) {
|
||||
McpConfig mcpConfig = new McpConfig();
|
||||
mcpConfig.setId(id);
|
||||
mcpConfig.setDeployStatus(DeployStatusEnum.DeployFailed);
|
||||
mcpConfigDomainService.update(mcpConfig);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user