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

cloud cmd api for platform client

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