提交 6a4cb00e authored 作者: blu's avatar blu

big refacting of communitation architect

上级 5284e474
......@@ -4,3 +4,6 @@
[submodule "opencv-motion-detect/vendor/leveldb"]
path = opencv-motion-detect/vendor/leveldb
url = https://github.com/google/leveldb
[submodule "opencv-motion-detect/vendor/curl"]
path = opencv-motion-detect/vendor/curl
url = https://github.com/curl/curl
......@@ -69,16 +69,16 @@ private:
int reloadCfg(string subModGid = "")
{
int bootType = 0;
if(subModGid == "ALL") {
bootType = 1;
}
else if(subModGid.empty()) {
bootType = 2;
}
else {
bootType = 3;
}
// int bootType = 0;
// if(subModGid == "ALL") {
// bootType = 1;
// }
// else if(subModGid.empty()) {
// bootType = 2;
// }
// else {
// bootType = 3;
// }
int ret = LVDB::getSn(this->info);
......@@ -102,22 +102,7 @@ private:
peerId = v["sn"].get<string>() + ":evmgr:0";
// offline
this->peerData["config"][peerId] = v;
if(this->peerData["status"].count(peerId) == 0||this->peerData["status"][peerId] == 0) {
this->peerData["status"][peerId] = 0;
if(bootType == 1 || (bootType == 3 && subModGid == peerId)) {
ret = zmqhelper::forkSubsystem(devSn, peerId, portRouter, pid);
if(ret != 0) {
spdlog::error("evdaemon {} failed to fork subsystem: {}", devSn, peerId);
// TODO: clean up and reload config
return -3;
}
this->peerData["pids"][peerId] = pid;
spdlog::info("evdaemon {} created subsystem {}", devSn, peerId);
}
}
else {
// TODO
}
}
// startup other submodules
......@@ -129,34 +114,22 @@ private:
if(m["sn"] != this->devSn) {
continue;
}
if(m.count("enabled") == 0 || m["enabled"] == 0) {
spdlog::warn("evdaemon {} {} was disabled, ignore", this->devSn, mn);
}
else {
string peerName;
ret = cfgutils::getPeerId(mn, m, peerId, peerName);
if(ret != 0) {
continue;
}
if(m.count("enabled") == 0 || m["enabled"] == 0) {
spdlog::warn("evdaemon {} {} was disabled", this->devSn, mn);
this->peerData["enabled"][peerId] = 0;
}else{
this->peerData["enabled"][peerId] = 1;
}
this->peerData["config"][peerId] = v;
if(this->peerData["status"].count(peerId) == 0||this->peerData["status"][peerId] == 0) {
this->peerData["status"][peerId] = 0;
if(bootType == 1 || (bootType == 3 && subModGid == peerId)) {
ret = zmqhelper::forkSubsystem(devSn, peerId, portRouter, pid);
if(ret != 0) {
spdlog::error("evdaemon {} failed to fork subsystem: {}", devSn, peerId);
// TODO: cleanup and reload
return -2;
}
this->peerData["pids"][peerId] = pid;
spdlog::info("evdaemon {} created subsystem {}", devSn, peerId);
}
}
else {
// TODO:
}
}
}
}
}
......@@ -197,7 +170,7 @@ private:
string info;
int cnt = 0;
for(auto &[k,v]: this->peerData["config"].items()) {
if(this->peerData["status"].count(k) == 0 || this->peerData["status"][k] == 0) {
if((this->peerData["status"].count(k) == 0 || this->peerData["status"][k] == 0) && this->peerData["enabled"] != 0) {
tmp.push_back(k);
info += (cnt == 0? "" : string(", ")) + k;
}
......@@ -256,17 +229,16 @@ private:
}
spdlog::warn("evdaemon {} peer {} disconnected. reloading config", devSn, selfId);
if(bBootstrap) {
ret = reloadCfg(selfId);
}
else {
ret = reloadCfg("");
}
ret = reloadCfg();
if(ret != 0) {
cleanupSubSystems();
spdlog::error("evdaemon {} failed to reload config. please check configuration", devSn);
return -1;
}
if(this->bBootstrap) {
startSubSystems();
}
}
// event
......
......@@ -148,10 +148,7 @@ private:
}
numSlices = 24 * days * 60 /minutes;
// alloc memory
sliceIdxToName = new vector<int>(numSlices);
// TODO: load db
// DB::exec(NULL, "select id, ts, last from slices;", DB::get_slices, sliceIdxToName);
spdlog::info("evslicer mkdir -p {}", selfId, urlOut);
ret = system((string("mkdir -p ") + urlOut).c_str());
// if(ret == -1) {
......
Subproject commit cb013830383f1ccc9757aba36bc32df5ec281c02
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论