提交 3c595cf3 authored 作者: blu's avatar blu

cloud cmd api for platform client

上级 8b03ad30
...@@ -382,10 +382,12 @@ private: ...@@ -382,10 +382,12 @@ private:
if(peerData["pids"].count(selfId) != 0) { if(peerData["pids"].count(selfId) != 0) {
peerData["pids"].erase(selfId); peerData["pids"].erase(selfId);
} }
spdlog::warn("evdaemon {} peer {} disconnected. reloading config", devSn, selfId);
if(this->bBootstrap) { if(this->bBootstrap) {
spdlog::warn("evdaemon {} peer {} disconnected. restarting it.", devSn, selfId);
startSubSystems({selfId}); startSubSystems({selfId});
}else{
spdlog::warn("evdaemon {} peer {} disconnected. won't restart it since BOOTSTRAP=false", devSn, selfId);
} }
} }
......
...@@ -145,6 +145,20 @@ error_exit: ...@@ -145,6 +145,20 @@ error_exit:
exit(1); exit(1);
} }
thCloudMsgHandler = thread([this] {
while(true)
{
auto body = z_recv_multiple(pDealer,false);
if(body.size() == 0) {
spdlog::error("evslicer {} failed to receive multiple msg: {}", this->devSn, zmq_strerror(zmq_errno()));
continue;
}
// full proto msg received.
this->handleCloudMsg(body);
}
});
thCloudMsgHandler.detach();
spdlog::info("evmgr {} successfuly inited", devSn); spdlog::info("evmgr {} successfuly inited", devSn);
} }
...@@ -172,8 +186,8 @@ error_exit: ...@@ -172,8 +186,8 @@ error_exit:
return -1; return -1;
} }
json *mod = LVDB::findConfigModule(config, sp[0], sp[1], stoi(sp[2])); json *mod = LVDB::findConfigModule(config, sp[0], sp[1], stoi(sp[2]));
if(mod == nullptr) { if(mod == nullptr||peerData["status"].count(selfId) == 0) {
spdlog::warn("evmgr {} failed to find module with id: {}", devSn, selfId); spdlog::warn("evmgr {} failed to find the connecting/disconnecting module with id {} in config. please check if it was terminated correctly", devSn, selfId);
return -1; return -1;
} }
...@@ -294,6 +308,7 @@ protected: ...@@ -294,6 +308,7 @@ protected:
{ {
bool bStopSig = false; bool bStopSig = false;
int ret = 0; int ret = 0;
while (true) { while (true) {
if(checkStop() == true) { if(checkStop() == true) {
bStopSig = true; bStopSig = true;
...@@ -303,20 +318,6 @@ protected: ...@@ -303,20 +318,6 @@ protected:
// spdlog::error("evmgr {} exit since evdaemon is dead", devSn); // spdlog::error("evmgr {} exit since evdaemon is dead", devSn);
// exit(1); // exit(1);
// } // }
thCloudMsgHandler = thread([this] {
while(true)
{
auto body = z_recv_multiple(pDealer,false);
if(body.size() == 0) {
spdlog::error("evslicer {} failed to receive multiple msg: {}", this->devSn, zmq_strerror(zmq_errno()));
continue;
}
// full proto msg received.
this->handleCloudMsg(body);
}
});
thCloudMsgHandler.detach();
auto body = z_recv_multiple(pRouter,false); auto body = z_recv_multiple(pRouter,false);
if(body.size() == 0) { if(body.size() == 0) {
......
...@@ -318,10 +318,10 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -318,10 +318,10 @@ 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("{}:{}: matching {}, size:{}, type:{}", __FILE__, __LINE__, diff.dump(), diff.size(), diff.type_name());
try{ try{
for(auto &d: diff) { for(auto &d: diff) {
spdlog::info("getModulesOperFromConfDiff path: {}", d.dump()); spdlog::info("{}:{}: path: {}", __FILE__, __LINE__, d.dump());
if(d.count("path") != 0) { if(d.count("path") != 0) {
string path_ = d["path"]; string path_ = d["path"];
bool matched = false; bool matched = false;
...@@ -340,7 +340,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -340,7 +340,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
std::smatch results; std::smatch results;
if (std::regex_match(path_, results, clusterRegex)) { if (std::regex_match(path_, results, clusterRegex)) {
if (results.size() == 3) { if (results.size() == 3) {
spdlog::info("getModulesOperFromConfDiff path matched ipc or ipc prop", path_); spdlog::info("{}:{}: path matched ipc or ipc prop: {}",__FILE__, __LINE__, path_);
matched = true; matched = true;
string mgrSn = results[1].str(); string mgrSn = results[1].str();
int ipcIdx = stoi(results[2].str()); int ipcIdx = stoi(results[2].str());
...@@ -351,7 +351,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -351,7 +351,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
mgr[mgrSn] = newConfig[mgrSn]; mgr[mgrSn] = newConfig[mgrSn];
} }
json jret = cfgutils::getModuleGidsFromCfg(sn, mgr, "getModulesOperFromConfDiff", ipcIdx); string info = string(__FILE__) + ":" + to_string(__LINE__);
json jret = cfgutils::getModuleGidsFromCfg(sn, mgr, info, ipcIdx);
spdlog::info("jret: {}", jret.dump()); spdlog::info("jret: {}", jret.dump());
if(jret["code"] != 0) { if(jret["code"] != 0) {
ret["msg"] = jret["msg"]; ret["msg"] = jret["msg"];
...@@ -383,7 +384,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -383,7 +384,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
if (std::regex_match(path_, results, moduleRegex)) { if (std::regex_match(path_, results, moduleRegex)) {
if (results.size() == 6) { if (results.size() == 6) {
matched = true; matched = true;
spdlog::info("getModulesOperFromConfDiff path matched module prop", path_); spdlog::info("{}:{}: path matched module prop: {}", __FILE__, __LINE__, path_);
string mgrSn = results[1].str(); string mgrSn = results[1].str();
int ipcIdx = stoi(results[2].str()); int ipcIdx = stoi(results[2].str());
int modIdx = stoi(results[4].str()); int modIdx = stoi(results[4].str());
...@@ -463,7 +464,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -463,7 +464,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
if (std::regex_match(path_, results, moduleRegex)) { if (std::regex_match(path_, results, moduleRegex)) {
if (results.size() == 5) { if (results.size() == 5) {
matched = true; matched = true;
spdlog::info("getModulesOperFromConfDiff path matched whole module", path_); spdlog::info("{}:{}: path matched whole module: {}", __FILE__, __LINE__, path_);
string mgrSn = results[1].str(); string mgrSn = results[1].str();
int ipcIdx = stoi(results[2].str()); int ipcIdx = stoi(results[2].str());
int modIdx = stoi(results[4].str()); int modIdx = stoi(results[4].str());
...@@ -525,7 +526,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -525,7 +526,7 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
if (std::regex_match(path_, results, clusterRegex)) { if (std::regex_match(path_, results, clusterRegex)) {
if (results.size() == 2) { if (results.size() == 2) {
matched = true; matched = true;
spdlog::info("getModulesOperFromConfDiff path matched whole cluster", path_); spdlog::info("{}:{}: path matched whole cluster: {}", path_);
string mgrSn = results[1].str(); string mgrSn = results[1].str();
json mgr; json mgr;
if(d["op"] == "remove"){ if(d["op"] == "remove"){
...@@ -534,8 +535,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -534,8 +535,8 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
mgr[mgrSn] = newConfig[mgrSn]; mgr[mgrSn] = newConfig[mgrSn];
} }
json jret = cfgutils::getModuleGidsFromCfg(sn, mgr, "getModulesOperFromConfDiff"); json jret = cfgutils::getModuleGidsFromCfg(sn, mgr, "");
spdlog::info("getModulesOperFromConfDiff getModuleGidsFromCfg: {}", jret.dump()); spdlog::info("{}:{} getModuleGidsFromCfg dump: {}", __FILE__, __LINE__, jret.dump());
if(jret["code"] != 0) { if(jret["code"] != 0) {
ret["msg"] = jret["msg"]; ret["msg"] = jret["msg"];
hasError = true; hasError = true;
...@@ -561,10 +562,10 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st ...@@ -561,10 +562,10 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
ret["code"] = 1; ret["code"] = 1;
} }
}catch(exception &e) { }catch(exception &e) {
string msg = fmt::format("getModulesOperFromConfDiff exception: {}", e.what()); string msg = fmt::format("{}:{}: exception: {}", __FILE__, __LINE__, e.what());
ret["code"] = -1; ret["code"] = -1;
ret["msg"] = msg; ret["msg"] = msg;
spdlog::error("getModulesOperFromConfDiff exception: {}", msg); spdlog::error("{}:{}: exception: {}", __FILE__, __LINE__, msg);
} }
return ret; return ret;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论