提交 0eeb7fc5 authored 作者: blu's avatar blu

big refacting of communitation architect

上级 5cc5ea4f
...@@ -108,7 +108,9 @@ class EvDaemon{ ...@@ -108,7 +108,9 @@ class EvDaemon{
if(m["sn"] != this->devSn) { if(m["sn"] != this->devSn) {
continue; continue;
} }
if(m["enabled"].get<int>() != 0) { if(m.count("enabled") == 0 || m["enabled"] == 0) {
spdlog::warn("evdaemon {} {} was disabled, ignore", this->devSn, mn);
}else{
string peerName; string peerName;
ret = cfgutils::getPeerId(mn, m, peerId, peerName); ret = cfgutils::getPeerId(mn, m, peerId, peerName);
if(ret != 0) { if(ret != 0) {
...@@ -143,28 +145,30 @@ class EvDaemon{ ...@@ -143,28 +145,30 @@ class EvDaemon{
return 0; return 0;
} }
void cleanupSubSystems(){
spdlog::info("evdaemon {} peerData {}", this->devSn, this->peerData.dump());
json &pd = this->peerData;
for(auto &[k,v]: pd["pids"].items()){
//kill(v, SIGTERM);
if(this->peerData["status"].count(k) != 0){
this->peerData["status"].erase(k);
}
if(this->peerData["config"].count(k) != 0){
this->peerData["config"].erase(k);
}
this->peerData["pids"].erase(k);
}
}
void setupSubSystems() { void setupSubSystems() {
thMon = thread([&, this](){ thMon = thread([this](){
while(true) { while(true) {
if(bReload) { if(bReload) {
int ret = reloadCfg(); int ret = reloadCfg();
if(ret != 0) { if(ret != 0) {
// cleanup cleanupSubSystems();
spdlog::info("evdaemon {} peerData {}", this->devSn, this->peerData.dump());
json &pd = this->peerData;
for(auto &[k,v]: pd["pids"].items()){
//kill(v, SIGTERM);
if(this->peerData["status"].count(k) != 0){
this->peerData["status"].erase(k);
}
if(this->peerData["config"].count(k) != 0){
this->peerData["config"].erase(k);
}
this->peerData["pids"].erase(k);
}
}else{ }else{
bReload = false; bReload = false;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论