提交 a831f6e7 authored 作者: blu's avatar blu

refactor of delta config

上级 4cb09d06
...@@ -133,7 +133,7 @@ private: ...@@ -133,7 +133,7 @@ private:
} }
if(m.count("enabled") == 0 || m["enabled"] == 0) { if(m.count("enabled") == 0 || m["enabled"] == 0) {
spdlog::warn("evdaemon {} {} was disabled", this->devSn, mn); spdlog::warn("evdaemon {} {} was disabled", this->devSn, peerId);
this->peerData["enabled"][peerId] = 0; this->peerData["enabled"][peerId] = 0;
} }
else { else {
...@@ -283,16 +283,15 @@ private: ...@@ -283,16 +283,15 @@ private:
json &mods = jret["data"]; json &mods = jret["data"];
for(auto &[k,v]: mods.items()) { for(auto &[k,v]: mods.items()) {
spdlog::info("evdaemon {} startSubSystems config diff to module action: {} -> {}", this->devSn, string(k), int(v));
if(v == 0) { if(v == 0) {
// send stop msg sendCmd2Peer(k, EV_MSG_META_VALUE_CMD_STOP, "0");
this->peerData["config"].erase(k); }else if(int(v) == 1 || int(v) == 2){
this->peerData["status"].erase(k); int status = (this->peerData["status"].count(k) == 0) ? -1:this->peerData["status"][k].get<int>();
this->peerData["pids"].erase(k); spdlog::info("{} status {}", k, status);
this->peerData["enabled"].erase(k); if(this->peerData["status"].count(k) == 0 || this->peerData["status"][k] == 0||this->peerData["status"][k] == -1) {
sendCmd2Peer(k, EV_MSG_META_VALUE_CMD_STOP, "");
}else if(v == 1 || v == 2){
if(this->peerData["status"].count(k) == 0 || this->peerData["status"] == 0) {
pid_t pid; pid_t pid;
spdlog::info("evdaemon {} starting subsystem {}", this->devSn, k);
ret = zmqhelper::forkSubsystem(devSn, k, portRouter, pid); ret = zmqhelper::forkSubsystem(devSn, k, portRouter, pid);
if(0 == ret) { if(0 == ret) {
this->peerData["status"][k] = 0; this->peerData["status"][k] = 0;
...@@ -304,7 +303,7 @@ private: ...@@ -304,7 +303,7 @@ private:
} }
}else{ }else{
// restart // restart
sendCmd2Peer(k, EV_MSG_META_VALUE_CMD_STOP, ""); sendCmd2Peer(k, EV_MSG_META_VALUE_CMD_STOP, to_string(v));
} }
}else{ }else{
// //
...@@ -320,11 +319,11 @@ private: ...@@ -320,11 +319,11 @@ private:
json meta; json meta;
meta["type"] = EV_MSG_META_TYPE_CMD; meta["type"] = EV_MSG_META_TYPE_CMD;
meta["value"] = cmdVal; meta["value"] = cmdVal;
int ret = z_send(pDealer, this->daemonId, peerId, meta, msg); int ret = z_send(pRouter, peerId, this->daemonId, meta, msg);
if(ret < 0) { if(ret < 0) {
spdlog::error("evcloudsvc {} failed to send msg to peer {}: {} - {}", devSn, peerId, meta.dump(), msg); spdlog::error("evdaemon {} failed to send msg to peer {}: {} - {}", devSn, peerId, meta.dump(), msg);
}else{ }else{
spdlog::info("evcloudsvc {} successfully send msg to peer {}: {} - {}", devSn, peerId, meta.dump(), msg); spdlog::info("evdaemon {} successfully send msg to peer {}: {} - {}", devSn, peerId, meta.dump(), msg);
} }
} }
......
...@@ -497,9 +497,9 @@ public: ...@@ -497,9 +497,9 @@ public:
continue; continue;
} }
// full proto msg received. // full proto msg received.
spdlog::info("evpusher {} received cloud msg: {}", this->selfId, "aaa");
this->handleCloudMsg(body); this->handleCloudMsg(body);
} }
}); });
thCloudMsgHandler.detach(); thCloudMsgHandler.detach();
...@@ -512,8 +512,7 @@ public: ...@@ -512,8 +512,7 @@ public:
} }
// full proto msg received. // full proto msg received.
this->handleEdgeMsg(body); this->handleEdgeMsg(body);
} }
}); });
thEdgeMsgHandler.detach(); thEdgeMsgHandler.detach();
......
...@@ -548,7 +548,7 @@ protected: ...@@ -548,7 +548,7 @@ protected:
for (const auto & entry : fs::directory_iterator(path)) { for (const auto & entry : fs::directory_iterator(path)) {
fname = entry.path().c_str(); fname = entry.path().c_str();
if(entry.file_size() == 0 || !entry.is_regular_file()||entry.path().extension() != ".mp4") { if(entry.file_size() == 0 || !entry.is_regular_file()||entry.path().extension() != ".mp4") {
spdlog::warn("evslicer {} LoasdVideoFiles skipped {} (empty/directory/!mp4)", selfId, entry.path().c_str()); spdlog::warn("evslicer {} LoadVideoFiles skipped {} (empty/directory/!mp4)", selfId, entry.path().c_str());
continue; continue;
} }
......
...@@ -282,7 +282,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -282,7 +282,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
ret["msg"] = "ok"; ret["msg"] = "ok";
ret["data"] = json(); ret["data"] = json();
bool hasError = false; bool hasError = false;
spdlog::info("matching {}, size:{}, type:{}", diff.dump(), diff.size(), diff.type_name()); spdlog::info("getModulesOperFromConfDiff for sn {}. diff: {}, newConfig: {}", sn, diff.dump(), newConfig.dump());
try { try {
for(auto &d: diff) { for(auto &d: diff) {
spdlog::info("d :{}, {}", d.dump(), d.size()); spdlog::info("d :{}, {}", d.dump(), d.size());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论