提交 5fab9b82 authored 作者: blu's avatar blu

big refacting of communitation architect

上级 62e44ec2
...@@ -83,9 +83,7 @@ class EvDaemon{ ...@@ -83,9 +83,7 @@ class EvDaemon{
if( (pid = fork()) == -1 ) { if( (pid = fork()) == -1 ) {
spdlog::error("evdamon {} failed to fork subsytem - evmgr", this->devSn); spdlog::error("evdamon {} failed to fork subsytem - evmgr", this->devSn);
}else if(pid == 0) { }else if(pid == 0) {
// child ret += setenv("GID", peerId.c_str(), 1);
// execl("./evmgr", "arg1", "arg2", (char *)0);
ret += setenv("SN", v["sn"].get<string>().c_str(), 1);
ret += setenv("DR_PORT", to_string(portRouter).c_str(), 1); ret += setenv("DR_PORT", to_string(portRouter).c_str(), 1);
if(ret < 0) { if(ret < 0) {
spdlog::error("evdaemon {} failed to set env", this->devSn); spdlog::error("evdaemon {} failed to set env", this->devSn);
...@@ -97,7 +95,7 @@ class EvDaemon{ ...@@ -97,7 +95,7 @@ class EvDaemon{
}else{ }else{
// parent // parent
spdlog::info("evdaemon {} created evmgr", this->devSn); spdlog::info("evdaemon {} created evmgr", this->devSn);
} }
} }
// startup other submodules // startup other submodules
...@@ -106,7 +104,14 @@ class EvDaemon{ ...@@ -106,7 +104,14 @@ class EvDaemon{
for(auto &ipc : ipcs) { for(auto &ipc : ipcs) {
json &modules = ipc["modules"]; json &modules = ipc["modules"];
for(auto &[mn, ml] : modules.items()) { for(auto &[mn, ml] : modules.items()) {
// for(auto &m : ml) {
if(m["sn"] != this->devSn) {
continue;
}
if(m["enabled"].get<int>() != 0) {
}
}
} }
} }
} }
......
...@@ -40,7 +40,7 @@ private: ...@@ -40,7 +40,7 @@ private:
void *pRouter = NULL; void *pRouter = NULL;
void *pCtxDealer = NULL, *pDealer = NULL; void *pCtxDealer = NULL, *pDealer = NULL;
json config; json config;
string devSn; string devSn, ident;
json peerStatus; json peerStatus;
unordered_map<string, queue<vector<vector<uint8_t> >> > cachedMsg; unordered_map<string, queue<vector<vector<uint8_t> >> > cachedMsg;
mutex cacheLock; mutex cacheLock;
...@@ -286,10 +286,16 @@ public: ...@@ -286,10 +286,16 @@ public:
exit(1); exit(1);
} }
strEnv = getenv("SN"); strEnv = getenv("GID");
if(strEnv != NULL) { if(strEnv != NULL) {
config["sn"] = strEnv; ident = strEnv;
devSn = strEnv; auto v = cloudutils::split(ident, ':');
if(v.size() != 3||v[1] != "evmgr" || v[2] != "0") {
spdlog::error("evmgr received invalid gid: {}", ident);
exit(1);
}
config["sn"] = v[0];
devSn = v[0];
}else{ }else{
spdlog::error("evmgr failed to start. no SN set"); spdlog::error("evmgr failed to start. no SN set");
exit(1); exit(1);
...@@ -297,7 +303,7 @@ public: ...@@ -297,7 +303,7 @@ public:
// //
string addr = string("tcp://127.0.0.1:") + to_string(config["dr-port"]); string addr = string("tcp://127.0.0.1:") + to_string(config["dr-port"]);
string ident = config["sn"].get<string>() + ":evmgr:0"; ident = config["sn"].get<string>() + ":evmgr:0";
int ret = zmqhelper::setupDealer(&pCtxDealer, &pDealer, addr, ident); int ret = zmqhelper::setupDealer(&pCtxDealer, &pDealer, addr, ident);
bool bConfigGot = false; bool bConfigGot = false;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论