[ server ] [ executor ]- shell executor optimize - 1

This commit is contained in:
zeaslity
2023-02-06 17:22:02 +08:00
parent f347cedce3
commit f4e636a368
4 changed files with 63 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
package io.wdd.agent.executor;
import com.google.common.io.ByteStreams;
import io.wdd.agent.config.utils.AgentCommonThreadPool;
import io.wdd.agent.executor.redis.StreamSender;
import io.wdd.agent.executor.thread.LogToArrayListCache;
import io.wdd.common.beans.executor.ExecutionMessage;
@@ -40,9 +41,13 @@ public class CommandExecutor {
* @param executionMessage get from EXECUTOR_HANDLER
*/
public void execute(ExecutionMessage executionMessage) {
this.execute(
executionMessage.getResultKey(),
executionMessage.getCommandList()
// 防止阻塞消息队列中的其他信息,需要使用异步执行
AgentCommonThreadPool.pool.submit(
() -> this.execute(
executionMessage.getResultKey(),
executionMessage.getCommandList()
)
);
}

View File

@@ -2,6 +2,7 @@ package io.wdd.agent.executor;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;
import io.wdd.agent.config.utils.AgentCommonThreadPool;
import io.wdd.agent.config.utils.NacosConfigurationCollector;
import io.wdd.common.beans.executor.ExecutionMessage;
import lombok.extern.slf4j.Slf4j;
@@ -44,7 +45,10 @@ public class FunctionExecutor {
completeCommandList = ALL_FUNCTION_MAP.get(executionMessage.getType());
}
this.execute(resultKey, completeCommandList);
// 防止阻塞消息队列中的其他信息,需要使用异步执行
AgentCommonThreadPool.pool.submit(
() -> this.execute(resultKey, completeCommandList)
);
}

View File

@@ -1,7 +1,46 @@
<!DOCTYPE html>
<html>
<head><title>Index of /octopus-agent/</title></head>
<head>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
</head>
<body>
<h1>Index of /octopus-agent/</h1><hr><pre><a href="../">../</a>
<a href="octopus-agent-2022-12-26-16-00-00.jar">octopus-agent-2022-12-26-16-00-00.jar</a> 27-Dec-2022 07:01 46309416
</pre><hr></body>
<canvas id="myChart" width="800" height="400"></canvas>
<script>
const ctx = document.getElementById("myChart").getContext("2d");
const myChart = new Chart(ctx, {
type: "line",
data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"],
datasets: [
{
label: "Data Set 1",
data: [1, 4, 2, 5, 3, 7, 6],
backgroundColor: "rgba(255, 99, 132, 0.2)",
borderColor: "rgba(255, 99, 132, 1)",
borderWidth: 1
},
{
label: "Data Set 2",
data: [2, 5, 4, 7, 6, 9, 8],
backgroundColor: "rgba(54, 162, 235, 0.2)",
borderColor: "rgba(54, 162, 235, 1)",
borderWidth: 1
}
]
},
options: {
scales: {
xAxes: [
{
type: "time",
time: {
unit: "month"
}
}
]
}
}
});
</script>
</body>
</html>

View File

@@ -6,6 +6,13 @@ start_time=$(date +%s)
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
log "开始执行CPU占用任务占用时间为 2小时"
while [ $elapsed_time -lt 7200 ]
do