提交 8c217d38 authored 作者: blu's avatar blu

improved log messages for subsystems

上级 19e1d622
...@@ -78,7 +78,7 @@ private: ...@@ -78,7 +78,7 @@ private:
queue<string> *evtQueue; queue<string> *evtQueue;
int streamIdx = -1; int streamIdx = -1;
json config; json config;
thread thEdgeMsgHandler, thCloudMsgHandler; thread thEdgeMsgHandler, thCloudMsgHandler, thHealdChecker;
thread thEvent; thread thEvent;
string drport = "5549"; string drport = "5549";
condition_variable cvMsg; condition_variable cvMsg;
...@@ -1053,6 +1053,28 @@ public: ...@@ -1053,6 +1053,28 @@ public:
exit(1); exit(1);
} }
// setup heath checker
thHealdChecker = thread([this]{
int cnt = 0;
uint64_t pktCntLast = pktCnt;
while(true){
if(cnt >=3) {
kill(getpid(), SIGTERM);
exit(1);
}
this_thread::sleep_for(chrono::seconds(30));
if(pktCntLast == pktCnt){
cnt++;
}else{
pktCntLast = pktCnt;
cnt = 0;
}
}
});
if(thHealdChecker.joinable()){
thHealdChecker.detach();
}
ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId); ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId);
if(ret != 0) { if(ret != 0) {
spdlog::error("{} failed to receive configration message {}", selfId, addr); spdlog::error("{} failed to receive configration message {}", selfId, addr);
......
...@@ -36,11 +36,12 @@ private: ...@@ -36,11 +36,12 @@ private:
AVFormatContext *pAVFormatRemux = nullptr; AVFormatContext *pAVFormatRemux = nullptr;
AVFormatContext *pAVFormatInput = nullptr; AVFormatContext *pAVFormatInput = nullptr;
json config; json config;
thread thCloudMsgHandler, thEdgeMsgHandler; thread thCloudMsgHandler, thEdgeMsgHandler, thHealdChecker;
string drport = "5549"; string drport = "5549";
condition_variable cvMsg; condition_variable cvMsg;
mutex mutMsg; mutex mutMsg;
bool gotFormat = false; bool gotFormat = false;
uint64_t pktCnt = 0;
int init() int init()
{ {
...@@ -488,7 +489,6 @@ protected: ...@@ -488,7 +489,6 @@ protected:
int ret = 0; int ret = 0;
zmq_msg_t msg; zmq_msg_t msg;
AVPacket packet; AVPacket packet;
uint64_t pktCnt = 0;
bool bStatsSent = false; bool bStatsSent = false;
while (true) { while (true) {
ret =zmq_msg_init(&msg); ret =zmq_msg_init(&msg);
...@@ -636,6 +636,28 @@ public: ...@@ -636,6 +636,28 @@ public:
exit(1); exit(1);
} }
// setup heath checker
thHealdChecker = thread([this]{
int cnt = 0;
uint64_t pktCntLast = pktCnt;
while(true){
if(cnt >=3) {
kill(getpid(), SIGTERM);
exit(1);
}
this_thread::sleep_for(chrono::seconds(30));
if(pktCntLast == pktCnt){
cnt++;
}else{
pktCntLast = pktCnt;
cnt = 0;
}
}
});
if(thHealdChecker.joinable()){
thHealdChecker.detach();
}
ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId); ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId);
if(ret != 0) { if(ret != 0) {
spdlog::error("{} failed to receive configration message {}", selfId, addr); spdlog::error("{} failed to receive configration message {}", selfId, addr);
......
...@@ -50,7 +50,7 @@ private: ...@@ -50,7 +50,7 @@ private:
AVDictionary *pOptsRemux = nullptr; AVDictionary *pOptsRemux = nullptr;
int *streamList = nullptr; int *streamList = nullptr;
json config; json config;
thread thEdgeMsgHandler, thCloudMsgHandler, thSliceMgr; thread thEdgeMsgHandler, thCloudMsgHandler, thSliceMgr, thHealdChecker;
string drport = "5549"; string drport = "5549";
json slices; json slices;
condition_variable cvMsg; condition_variable cvMsg;
...@@ -63,6 +63,7 @@ private: ...@@ -63,6 +63,7 @@ private:
string videoFileServerApi = "http://139.219.142.18:10008/upload/evtvideos/"; string videoFileServerApi = "http://139.219.142.18:10008/upload/evtvideos/";
set<long> sTsList; set<long> sTsList;
mutex mutTsList; mutex mutTsList;
uint64_t pktCnt = 0;
bool validMsg(json &msg) bool validMsg(json &msg)
...@@ -514,7 +515,6 @@ protected: ...@@ -514,7 +515,6 @@ protected:
void run() void run()
{ {
int ret = 0; int ret = 0;
int pktCnt = 0;
AVStream * out_stream = nullptr; AVStream * out_stream = nullptr;
zmq_msg_t msg; zmq_msg_t msg;
AVPacket packet; AVPacket packet;
...@@ -954,6 +954,30 @@ public: ...@@ -954,6 +954,30 @@ public:
exit(1); exit(1);
} }
// health checker
// setup heath checker
thHealdChecker = thread([this]{
int cnt = 0;
uint64_t pktCntLast = pktCnt;
while(true){
if(cnt >=3) {
kill(getpid(), SIGTERM);
exit(1);
}
this_thread::sleep_for(chrono::seconds(30));
if(pktCntLast == pktCnt){
cnt++;
}else{
pktCntLast = pktCnt;
cnt = 0;
}
}
});
if(thHealdChecker.joinable()){
thHealdChecker.detach();
}
ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId); ret = zmqhelper::recvConfigMsg(pDaemon, config, addr, selfId);
if(ret != 0) { if(ret != 0) {
spdlog::error("{} failed to receive configration message {}", selfId, addr); spdlog::error("{} failed to receive configration message {}", selfId, addr);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论