multi front process
This commit is contained in:
@@ -534,7 +534,7 @@ int terminal_ledger_web(std::map<std::string, terminal_dev>& terminal_dev_map,
|
||||
{
|
||||
if (inputstring.empty()) {
|
||||
std::cerr << "Error: inputstring is empty\n";
|
||||
DIY_ERRORLOG("process","【ERROR】前置的%s%d号进程调用web台账接口的入参为空", get_front_msg_from_subdir(), g_front_seg_index);
|
||||
DIY_ERRORLOG("process","【ERROR】前置的%d号进程调用web台账接口的入参为空", g_front_seg_index);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -672,7 +672,8 @@ int terminal_ledger_web(std::map<std::string, terminal_dev>& terminal_dev_map,
|
||||
}
|
||||
|
||||
// 5. 主进程保存台账
|
||||
if (g_node_id == STAT_DATA_BASE_NODE_ID && g_front_seg_index == 1) {
|
||||
//if (g_node_id == STAT_DATA_BASE_NODE_ID && g_front_seg_index == 1) {
|
||||
if (g_front_seg_index == 1) {
|
||||
save_ledger_json(responseStr);
|
||||
}
|
||||
|
||||
@@ -691,7 +692,7 @@ int parse_device_cfg_web()
|
||||
input_jstr += "}";
|
||||
|
||||
std::cout << "input_jstr: " << input_jstr << std::endl;
|
||||
DIY_DEBUGLOG("process","【DEBUG】前置的%s%d号进程调用web接口获取台账使用的请求输入为:%s",get_front_msg_from_subdir(), g_front_seg_index, input_jstr.c_str());
|
||||
DIY_DEBUGLOG("process","【DEBUG】前置的%d号进程调用web接口获取台账使用的请求输入为:%s", g_front_seg_index, input_jstr.c_str());
|
||||
|
||||
// 2. 调用接口
|
||||
std::map<std::string, terminal_dev> terminal_dev_map;
|
||||
@@ -702,8 +703,9 @@ int parse_device_cfg_web()
|
||||
// 3. 调试打印
|
||||
printTerminalDevMap(terminal_dev_map);
|
||||
|
||||
// 4. 看门狗配置校验(仅主进程稳态)
|
||||
if (g_node_id == STAT_DATA_BASE_NODE_ID && g_front_seg_index == 1) {
|
||||
// 4. 看门狗配置校验(仅主进程)
|
||||
//if (g_node_id == STAT_DATA_BASE_NODE_ID && g_front_seg_index == 1) {
|
||||
if (g_front_seg_index == 1) {
|
||||
int max_index = get_max_stat_data_index(FRONT_PATH + "/etc/runtime.cf");
|
||||
std::cout << "max_index = " << max_index << std::endl;
|
||||
|
||||
@@ -730,13 +732,13 @@ int parse_device_cfg_web()
|
||||
// 5. 台账数量与配置比对
|
||||
int count_cfg = static_cast<int>(terminal_dev_map.size());
|
||||
std::cout << "terminal_ledger_num: " << count_cfg << std::endl;
|
||||
DIY_DEBUGLOG("process", "【DEBUG】前置的%s%d号进程调用获取到的台账的数量为:%d",get_front_msg_from_subdir(), g_front_seg_index, count_cfg);
|
||||
DIY_DEBUGLOG("process", "【DEBUG】前置的%d号进程调用获取到的台账的数量为:%d", g_front_seg_index, count_cfg);
|
||||
|
||||
if (IED_COUNT < count_cfg) {
|
||||
std::cout << "!!!!!!!!!!single process can not add any ledger unless reboot!!!!!!!" << std::endl;
|
||||
DIY_WARNLOG("process","【WARN】前置的%s%d号进程获取到的台账的数量大于配置文件中给单个进程配置的台账数量:%d,这个进程将按照获取到的台账的数量来创建台账空间,这个进程不能直接通过台账添加来新增台账,只能通过重启进程或者先删除已有台账再添加台账的方式来添加新台账",get_front_msg_from_subdir(), g_front_seg_index, IED_COUNT);
|
||||
DIY_WARNLOG("process","【WARN】前置的%d号进程获取到的台账的数量大于配置文件中给单个进程配置的台账数量:%d,这个进程将按照获取到的台账的数量来创建台账空间,这个进程不能直接通过台账添加来新增台账,只能通过重启进程或者先删除已有台账再添加台账的方式来添加新台账", g_front_seg_index, IED_COUNT);
|
||||
} else {
|
||||
DIY_INFOLOG("process","【NORMAL】前置的%s%d号进程根据配置文件中给单个进程配置的台账数量:%d来创建台账空间",get_front_msg_from_subdir(), g_front_seg_index, IED_COUNT);
|
||||
DIY_INFOLOG("process","【NORMAL】前置的%d号进程根据配置文件中给单个进程配置的台账数量:%d来创建台账空间", g_front_seg_index, IED_COUNT);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////用例这里将局部的map拷贝到全局map,后续根据协议台账修改
|
||||
@@ -883,7 +885,7 @@ int parse_model_cfg_web()
|
||||
// 3. 调用接口
|
||||
std::map<std::string, icd_model*> icd_model_map;
|
||||
if (parse_model_web(&icd_model_map, input_jstr)) {
|
||||
DIY_ERRORLOG("process", "【ERROR】前置的%s%d号进程 icd模型接口异常,将使用默认的icd模型,请检查接口配置",get_front_msg_from_subdir(), g_front_seg_index);
|
||||
DIY_ERRORLOG("process", "【ERROR】前置的%d号进程 icd模型接口异常,将使用默认的icd模型,请检查接口配置", g_front_seg_index);
|
||||
// 确保释放 map
|
||||
for (auto& kv : icd_model_map) delete kv.second;
|
||||
return 0;
|
||||
@@ -937,7 +939,7 @@ std::string parse_model_cfg_web_one(const std::string& terminal_type)
|
||||
// 2. 拉取并解析
|
||||
if (parse_model_web(&icd_model_map, input_jstr) != 0) {
|
||||
std::cerr << "parse_model_web failed for type: " << terminal_type << std::endl;
|
||||
DIY_ERRORLOG("process","【ERROR】前置的%s%d号进程 icd模型接口异常,将使用默认的icd模型,请检查接口配置",get_front_msg_from_subdir(), g_front_seg_index);
|
||||
DIY_ERRORLOG("process","【ERROR】前置的%d号进程 icd模型接口异常,将使用默认的icd模型,请检查接口配置", g_front_seg_index);
|
||||
// 清理(即使 map 为空,也安全)
|
||||
for (auto& kv : icd_model_map) delete kv.second;
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user