优化日志,而且台账修改时无论什么状态都先关闭连接
This commit is contained in:
@@ -45,7 +45,7 @@ extern std::string intToString(int number);
|
||||
int StringToInt(const std::string& str);
|
||||
extern pthread_mutex_t mtx;//lnk20250115
|
||||
|
||||
|
||||
extern int RECALL_ONLY_FLAG; //lnk20260309添加一个全局变量,标志是否只运行补招程序
|
||||
|
||||
extern void SendFileWeb(const std::string& strUrl,
|
||||
const char* localpath,
|
||||
@@ -1022,7 +1022,7 @@ int parse_set(const std::string& json_str) {
|
||||
//进程号为0或者进程号匹配上
|
||||
std::cout << "msg index:"<< index_value <<" self index:" << g_front_seg_index << std::endl;
|
||||
|
||||
DIY_INFOLOG("process","【NORMAL】前置的%s%d号进程处理topic:%s_%s的进程控制消息",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_SET.c_str());
|
||||
DIY_INFOLOG_CODE("process",0,LOG_CODE_PROCESS_CONTROL,"【NORMAL】前置的%s%d号进程处理topic:%s_%s的进程控制消息",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_SET.c_str());
|
||||
|
||||
if (code_str == "set_process") {
|
||||
|
||||
@@ -1049,7 +1049,7 @@ int parse_set(const std::string& json_str) {
|
||||
}
|
||||
execute_bash(fun, processNum, frontType);
|
||||
|
||||
DIY_WARNLOG_CODE("process",LOG_CODE_PROCESS_CONTROL,"【WARN】前置的%s%d号进程执行指令:%s,reset表示重启所有进程,add表示添加进程",get_front_msg_from_subdir(), g_front_seg_index,fun.c_str());
|
||||
DIY_WARNLOG_CODE("process",0,LOG_CODE_PROCESS_CONTROL,"【WARN】前置的%s%d号进程执行指令:%s,reset表示重启所有进程,add表示添加进程",get_front_msg_from_subdir(), g_front_seg_index,fun.c_str());
|
||||
|
||||
//脚本在3秒后执行
|
||||
//回复消息
|
||||
@@ -1071,7 +1071,7 @@ int parse_set(const std::string& json_str) {
|
||||
send_reply_to_kafka(guid,"1","收到删除进程指令,这个进程将会重启 ");
|
||||
|
||||
//上送日志
|
||||
DIY_WARNLOG_CODE("process",LOG_CODE_PROCESS_CONTROL,"【WARN】前置的%s%d号进程执行指令:%s,即将重启",get_front_msg_from_subdir(), g_front_seg_index,fun.c_str());
|
||||
DIY_WARNLOG_CODE("process",0,LOG_CODE_PROCESS_CONTROL,"【WARN】前置的%s%d号进程执行指令:%s,即将重启",get_front_msg_from_subdir(), g_front_seg_index,fun.c_str());
|
||||
|
||||
apr_sleep(apr_time_from_sec(10));
|
||||
::_exit(-1039); //进程退出
|
||||
@@ -1114,7 +1114,7 @@ int parse_set(const std::string& json_str) {
|
||||
(proindex >= 10 && proindex < 100)){ //单连测试用的进程号应该大于10小于100
|
||||
execute_bash_debug(fun, ip, frontType,proindex);
|
||||
|
||||
DIY_WARNLOG("process","【WARN】前置的%s%d号进程执行指令:%s,start开启单连进程,delete杀死单连进程",get_front_msg_from_subdir(), g_front_seg_index,fun.c_str());
|
||||
DIY_WARNLOG_CODE("process",0,LOG_CODE_PROCESS_CONTROL,"【WARN】前置的%s%d号进程执行指令:%s,start开启单连进程,delete杀死单连进程",get_front_msg_from_subdir(), g_front_seg_index,fun.c_str());
|
||||
}
|
||||
else{
|
||||
std::cout << "param is not executable" <<std::endl;
|
||||
@@ -1471,7 +1471,7 @@ int parse_log(const std::string& json_str) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DIY_INFOLOG("process","【NORMAL】前置的%s%d号进程处理日志上送消息",get_front_msg_from_subdir(), g_front_seg_index);
|
||||
DIY_INFOLOG_CODE("process",0,LOG_CODE_LOG_REQUEST,"【NORMAL】前置的%s%d号进程处理日志上送消息",get_front_msg_from_subdir(), g_front_seg_index);
|
||||
|
||||
//进程号和匹配上
|
||||
std::cout << "msg index:"<< processNo <<" self index:" << g_front_seg_index << std::endl;
|
||||
@@ -1588,7 +1588,7 @@ int parse_control(const std::string& json_str, const std::string& output_dir) {
|
||||
std::cout << "msg index:"<< process_No <<" self index:" << g_front_seg_index << std::endl;
|
||||
|
||||
//记录日志
|
||||
DIY_INFOLOG("process","【NORMAL】前置的%s%d号进程处理topic:%s_%s的台账更新消息",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_UD.c_str());
|
||||
DIY_INFOLOG_CODE("process",0,LOG_CODE_LEDGER_UPDATE,"【NORMAL】前置的%s%d号进程处理topic:%s_%s的台账更新消息",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_UD.c_str());
|
||||
|
||||
//匹配后响应收到台账更新消息
|
||||
//除了回复收到消息,执行结束后还要回复结果
|
||||
@@ -2141,7 +2141,7 @@ static int HandleTypeDownloadAndUpload(chnl_usr_t* chnl_usr,
|
||||
char localpath[512] = {0};
|
||||
if (BuildTempLocalPath(localpath, sizeof(localpath), chnl_usr, req->path) != 0)
|
||||
{
|
||||
DIY_ERRORLOG_CODE("process", LOG_CODE_TRANSIENT_COMM,
|
||||
DIY_ERRORLOG_CODE("process",0, LOG_CODE_TRANSIENT_COMM,
|
||||
"【ERROR】构造本地临时路径失败 devid=%s path=%s",
|
||||
req->devid, req->path);
|
||||
|
||||
@@ -2156,7 +2156,7 @@ static int HandleTypeDownloadAndUpload(chnl_usr_t* chnl_usr,
|
||||
|
||||
if (ret != SD_SUCCESS)
|
||||
{
|
||||
DIY_ERRORLOG_CODE("process", LOG_CODE_TRANSIENT_COMM,
|
||||
DIY_ERRORLOG_CODE("process",0, LOG_CODE_TRANSIENT_COMM,
|
||||
"【ERROR】装置文件下载失败 devid=%s, rem=%s, ret=0x%X",
|
||||
req->devid, req->path, ret);
|
||||
|
||||
@@ -2164,7 +2164,7 @@ static int HandleTypeDownloadAndUpload(chnl_usr_t* chnl_usr,
|
||||
return -1;
|
||||
}
|
||||
|
||||
DIY_INFOLOG("process",
|
||||
DIY_INFOLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【NORMAL】装置文件下载成功 devid=%s, rem=%s, local=%s",
|
||||
req->devid, req->path, localpath);
|
||||
|
||||
@@ -2192,7 +2192,7 @@ static int HandleTypeTransferToDevice(chnl_usr_t* chnl_usr,
|
||||
char localpath[512] = {0};
|
||||
if (BuildTempLocalPath(localpath, sizeof(localpath), chnl_usr, req->path) != 0)
|
||||
{
|
||||
DIY_ERRORLOG_CODE("process", LOG_CODE_TRANSIENT_COMM,
|
||||
DIY_ERRORLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【ERROR】构造本地临时路径失败 devid=%s path=%s",
|
||||
req->devid, req->path);
|
||||
|
||||
@@ -2203,7 +2203,7 @@ static int HandleTypeTransferToDevice(chnl_usr_t* chnl_usr,
|
||||
int dlRet = DownloadFileWeb(WEB_FILEDOWNLOAD, req->path, localpath);
|
||||
if (dlRet != 0)
|
||||
{
|
||||
DIY_ERRORLOG_CODE("process", LOG_CODE_TRANSIENT_COMM,
|
||||
DIY_ERRORLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【ERROR】Web 文件下载失败 devid=%s, path=%s",
|
||||
req->devid, req->path);
|
||||
|
||||
@@ -2211,7 +2211,7 @@ static int HandleTypeTransferToDevice(chnl_usr_t* chnl_usr,
|
||||
return -1;
|
||||
}
|
||||
|
||||
DIY_INFOLOG("process",
|
||||
DIY_INFOLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【NORMAL】Web 文件下载成功 devid=%s, webpath=%s, local=%s",
|
||||
req->devid, req->path, localpath);
|
||||
|
||||
@@ -2227,7 +2227,7 @@ static int HandleTypeTransferToDevice(chnl_usr_t* chnl_usr,
|
||||
|
||||
if (ret != SD_SUCCESS)
|
||||
{
|
||||
DIY_ERRORLOG_CODE("process", LOG_CODE_TRANSIENT_COMM,
|
||||
DIY_ERRORLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【ERROR】文件传送到装置失败 devid=%s, src=%s, dest=%s, ret=0x%X",
|
||||
req->devid, localpath, destfilename, ret);
|
||||
|
||||
@@ -2235,7 +2235,7 @@ static int HandleTypeTransferToDevice(chnl_usr_t* chnl_usr,
|
||||
return -1;
|
||||
}
|
||||
|
||||
DIY_INFOLOG("process",
|
||||
DIY_INFOLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【NORMAL】文件传送到装置成功 devid=%s, src=%s, dest=%s",
|
||||
req->devid, localpath, destfilename);
|
||||
|
||||
@@ -2266,7 +2266,7 @@ void HandleFileDirReqForChannel(chnl_usr_t *chnl_usr)
|
||||
if (req == NULL)
|
||||
return; // 当前连接没有文件请求
|
||||
|
||||
DIY_INFOLOG("process",
|
||||
DIY_INFOLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【NORMAL】处理文件请求 terminal_id=%s type=%d path=%s",
|
||||
req->devid, req->type, req->path);
|
||||
|
||||
@@ -2291,7 +2291,7 @@ void HandleFileDirReqForChannel(chnl_usr_t *chnl_usr)
|
||||
filenum,
|
||||
(ret == SD_SUCCESS) ? 0 : ret);
|
||||
|
||||
DIY_INFOLOG("process",
|
||||
DIY_INFOLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【NORMAL】目录请求处理完成 terminal_id=%s ret=0x%X filenum=%d",
|
||||
req->devid, ret, filenum);
|
||||
|
||||
@@ -2309,7 +2309,7 @@ void HandleFileDirReqForChannel(chnl_usr_t *chnl_usr)
|
||||
}
|
||||
else
|
||||
{
|
||||
DIY_WARNLOG("process",
|
||||
DIY_WARNLOG_CODE(req->devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【WARN】未知文件请求类型 type=%d devid=%s path=%s",
|
||||
req->type, req->devid, req->path);
|
||||
|
||||
@@ -2391,7 +2391,7 @@ int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg)
|
||||
}
|
||||
else{
|
||||
//记录日志
|
||||
DIY_INFOLOG("process","【NORMAL】前置消费topic:%s_%s的实时触发消息",FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_RT.c_str());
|
||||
DIY_INFOLOG_CODE("process",0,LOG_CODE_RT_DATA,"【NORMAL】前置消费topic:%s_%s的实时触发消息",FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_RT.c_str());
|
||||
|
||||
// 处理消息(例如,打印消息内容)
|
||||
std::cout << "rt data Callback received message: " << body << std::endl;
|
||||
@@ -2410,7 +2410,7 @@ int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg)
|
||||
if (!parseJsonMessageRT(body, devid, line, realData, soeData, limit)) {
|
||||
std::cerr << "Failed to parse the JSON message." << std::endl;
|
||||
//记录日志
|
||||
DIY_ERRORLOG_CODE("process",LOG_CODE_RT_DATA,"【ERROR】前置消费topic:%s_%s的实时触发消息失败,消息的json格式不正确",FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_RT.c_str());
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_RT_DATA,"【ERROR】前置消费topic:%s_%s的实时触发消息失败,消息的json格式不正确",FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_RT.c_str());
|
||||
return E_RECONSUME_LATER;
|
||||
}
|
||||
|
||||
@@ -2428,7 +2428,7 @@ int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg)
|
||||
}
|
||||
// 创建 XML 文件
|
||||
if (!createXmlFile(dev_index, mp_index, realData, soeData, limit,"new")) {
|
||||
DIY_ERRORLOG_CODE("process",LOG_CODE_RT_DATA,"【ERROR】前置无法创建实时数据触发文件");
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_RT_DATA,"【ERROR】前置无法创建实时数据触发文件");
|
||||
std::cerr << "Failed to create the XML file." << std::endl;
|
||||
return E_RECONSUME_LATER;
|
||||
}
|
||||
@@ -2467,9 +2467,15 @@ int myMessageCallbackupdate(CPushConsumer* consumer, CMessageExt* msg)
|
||||
}
|
||||
|
||||
//处理台账更新消息
|
||||
std::string updatefilepath = "/home/pq/FeProject/etc/ledgerupdate";
|
||||
if(parse_control(body,updatefilepath)){
|
||||
DIY_ERRORLOG_CODE("process",LOG_CODE_LEDGER_UPDATE,"【ERROR】前置的%s%d号进程处理topic:%s_%s的台账更新消息失败,消息的json结构不正确",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_UD.c_str());
|
||||
if(RECALL_ONLY_FLAG != 1 || (g_node_id != STAT_DATA_BASE_NODE_ID)) {
|
||||
std::string updatefilepath = "/FeProject/etc/ledgerupdate";
|
||||
if(parse_control(body,updatefilepath)){
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_LEDGER_UPDATE,"【ERROR】前置的%s%d号进程处理topic:%s_%s的台账更新消息失败,消息的json结构不正确",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_UD.c_str());
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("only process recall config, skip ledger update\n");
|
||||
DIY_WARNLOG_CODE("process",0,LOG_CODE_SPACE_ALARM,"【WARN】当前配置为仅日志模式,统计数据进程跳过台账更新");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2505,7 +2511,7 @@ int myMessageCallbackset(CPushConsumer* consumer, CMessageExt* msg)
|
||||
|
||||
//处理进程更新消息
|
||||
if(parse_set(body)){
|
||||
DIY_ERRORLOG_CODE("process",LOG_CODE_PROCESS_CONTROL,"【ERROR】前置的%s%d号进程处理topic:%s_%s的进程控制消息失败,消息的json结构不正确",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_SET.c_str());
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_PROCESS_CONTROL,"【ERROR】前置的%s%d号进程处理topic:%s_%s的进程控制消息失败,消息的json结构不正确",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_SET.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2541,7 +2547,7 @@ int myMessageCallbacklog(CPushConsumer* consumer, CMessageExt* msg)
|
||||
|
||||
//处理进程更新消息
|
||||
if(parse_log(body)){
|
||||
DIY_ERRORLOG_CODE("process",LOG_CODE_LOG_REQUEST,"【ERROR】前置的%s%d号进程处理topic:%s_%s的日志上送消息失败,消息的json结构不正确",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_LOG.c_str());
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_LOG_REQUEST,"【ERROR】前置的%s%d号进程处理topic:%s_%s的日志上送消息失败,消息的json结构不正确",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_LOG.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2590,7 +2596,7 @@ int myMessageCallbackrecall(CPushConsumer* consumer, CMessageExt* msg)
|
||||
}
|
||||
else{
|
||||
std::cerr << "recall data is NULL." << std::endl;
|
||||
DIY_ERRORLOG_CODE("process",LOG_CODE_RECALL,"【ERROR】前置的%s%d号进程处理topic:%s_%s的补招触发消息失败,消息的json结构不正确",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_RC.c_str());
|
||||
DIY_ERRORLOG_CODE("process",0,LOG_CODE_RECALL,"【ERROR】前置的%s%d号进程处理topic:%s_%s的补招触发消息失败,消息的json结构不正确",get_front_msg_from_subdir(), g_front_seg_index,FRONT_INST.c_str(),G_MQCONSUMER_TOPIC_RC.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2616,7 +2622,7 @@ int myMessageCallbackfile(CPushConsumer* consumer, CMessageExt* msg)
|
||||
return E_RECONSUME_LATER;
|
||||
}
|
||||
|
||||
DIY_INFOLOG("process","【NORMAL】前置消费topic:%s_%s的文件控制消息",
|
||||
DIY_INFOLOG_CODE("process",0,LOG_CODE_FILE_CONTROL,"【NORMAL】前置消费topic:%s_%s的文件控制消息",
|
||||
FRONT_INST.c_str(), G_MQCONSUMER_TOPIC_FILE.c_str());
|
||||
|
||||
std::cout << "file Callback received message: " << body << std::endl;
|
||||
@@ -2625,13 +2631,13 @@ int myMessageCallbackfile(CPushConsumer* consumer, CMessageExt* msg)
|
||||
file_dir_req_t req;
|
||||
if (ParseFileDirReq(body, &req) != 0)
|
||||
{
|
||||
DIY_WARNLOG("process", "【WARN】文件控制消息解析失败: %s", body);
|
||||
DIY_WARNLOG_CODE(req.devid,1,LOG_CODE_FILE_CONTROL,"【WARN】文件控制消息解析失败: %s", body);
|
||||
return E_CONSUME_SUCCESS;
|
||||
}
|
||||
|
||||
PushFileDirReq(&req);
|
||||
|
||||
DIY_INFOLOG("process",
|
||||
DIY_INFOLOG_CODE(req.devid,1, LOG_CODE_FILE_CONTROL,
|
||||
"【NORMAL】文件目录请求已入队 guid=%s devid=%s path=%s",
|
||||
req.guid, req.devid, req.path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user