[ server ] [ agent ]- 收集Agent的版本信息 初步完成 - 2; 增加OpenFeign; 优化代码
This commit is contained in:
@@ -48,6 +48,7 @@ public class OMHandlerExecutor extends AbstractOctopusMessageHandler {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// add in 2023-1-17
|
||||
if (CollectionUtils.isNotEmpty(executionMessage.getScriptCommandList())) {
|
||||
// 传递的是 页面定时任务脚本
|
||||
|
||||
@@ -42,6 +42,7 @@ public class CommandExecutor {
|
||||
*/
|
||||
public void execute(ExecutionMessage executionMessage) {
|
||||
|
||||
// todo 需要长时间执行的任务 与目前的系统设计存在冲突 防卡死后台进程`出现问题
|
||||
// 防止阻塞消息队列中的其他信息,需要使用异步执行
|
||||
AgentCommonThreadPool.pool.submit(
|
||||
() -> this.execute(
|
||||
|
||||
@@ -26,9 +26,16 @@
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!--<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<!-- add in 2023-02-08 needed for some operation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
<version>2.2.9.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 2023-1-10 introduce the quartz framework -->
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.wdd.rpc.agent;
|
||||
|
||||
import io.wdd.server.beans.vo.ServerInfoVO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface OctopusAgentService {
|
||||
@@ -13,4 +15,18 @@ public interface OctopusAgentService {
|
||||
Map<String, String> getAllAgentVersion();
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有Agent的核心信息,方便更新系统信息
|
||||
*
|
||||
* @return agent-topic-name value -agentServerInfo
|
||||
*/
|
||||
Map<String, ServerInfoVO> getAllAgentCoreInfo();
|
||||
|
||||
|
||||
/**
|
||||
* 执行 Agent 关键操作的接口
|
||||
* 关机
|
||||
* */
|
||||
String shutdownAgentDanger(String agentTopicName);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.wdd.common.beans.rabbitmq.OctopusMessage;
|
||||
import io.wdd.common.beans.rabbitmq.OctopusMessageType;
|
||||
import io.wdd.common.utils.TimeUtils;
|
||||
import io.wdd.rpc.message.sender.OMessageToAgentSender;
|
||||
import io.wdd.server.beans.vo.ServerInfoVO;
|
||||
import io.wdd.server.config.ServerCommonPool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -70,6 +71,17 @@ public class OctopusAgentServiceImpl implements OctopusAgentService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ServerInfoVO> getAllAgentCoreInfo() {
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shutdownAgentDanger(String agentTopicName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void waitCollectAllAgentVersionInfo(HashMap<String, String> result, LocalDateTime startTime) {
|
||||
|
||||
CompletableFuture<Void> getAllAgentVersionInfo = new CompletableFuture<>();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package io.wdd.rpc.openfeign;
|
||||
|
||||
public class AgentOperationFeign {
|
||||
}
|
||||
@@ -7,10 +7,10 @@ current_time=$(date +%s)
|
||||
elapsed_time=$((current_time - start_time))
|
||||
|
||||
|
||||
if [[ $(ps -ef | grep -v "color" |grep -c "/octopus-agent/shell/function/load50cpu_2_hour") -gt 0 ]]; then
|
||||
log "已经存在CPU占用进程 !杀死该进程"
|
||||
kill -9 $(ps -ef | grep -v "color" |grep "/octopus-agent/shell/function/load50cpu_2_hour" | awk '{print$2}')
|
||||
fi
|
||||
#if [[ $(ps -ef | grep -v "color" |grep -c "/octopus-agent/shell/function/load50cpu_2_hour") -gt 0 ]]; then
|
||||
# log "已经存在CPU占用进程 !杀死该进程"
|
||||
# kill -9 $(ps -ef | grep -v "color" |grep "/octopus-agent/shell/function/load50cpu_2_hour" | awk '{print$2}')
|
||||
#fi
|
||||
|
||||
|
||||
log "开始执行CPU占用任务,占用时间为 2小时!"
|
||||
|
||||
Reference in New Issue
Block a user