新增getWorkThreadsLoad接口

This commit is contained in:
xiongziliang 2019-10-24 11:21:55 +08:00
parent a739bd7304
commit 1f89a86892

View File

@ -45,6 +45,7 @@
#include "Util/MD5.h" #include "Util/MD5.h"
#include "WebApi.h" #include "WebApi.h"
#include "WebHook.h" #include "WebHook.h"
#include "Thread/WorkThreadPool.h"
#if !defined(_WIN32) #if !defined(_WIN32)
#include "FFmpegSource.h" #include "FFmpegSource.h"
@ -281,6 +282,23 @@ void installWebApi() {
}); });
}); });
//获取后台工作线程负载
//测试url http://127.0.0.1/index/api/getWorkThreadsLoad
API_REGIST_INVOKER(api, getWorkThreadsLoad, {
WorkThreadPool::Instance().getExecutorDelay([invoker, headerOut](const vector<int> &vecDelay) {
Value val;
auto vec = WorkThreadPool::Instance().getExecutorLoad();
int i = 0;
for (auto load : vec) {
Value obj(objectValue);
obj["load"] = load;
obj["delay"] = vecDelay[i++];
val["data"].append(obj);
}
invoker("200 OK", headerOut, val.toStyledString());
});
});
//获取服务器配置 //获取服务器配置
//测试url http://127.0.0.1/index/api/getServerConfig //测试url http://127.0.0.1/index/api/getServerConfig
API_REGIST(api, getServerConfig, { API_REGIST(api, getServerConfig, {