提交 c6336990 authored 作者: blu's avatar blu

evcloudsvc bugfix: exception get evmgr config

上级 b095f5ce
...@@ -221,35 +221,42 @@ class HttpSrv{ ...@@ -221,35 +221,42 @@ class HttpSrv{
ret["msg"] = "evcloud bad req: no sn/module param"; ret["msg"] = "evcloud bad req: no sn/module param";
spdlog::error(ret["msg"].get<string>()); spdlog::error(ret["msg"].get<string>());
}else{ }else{
string modname = module.substr(0,4); try{
string key; string modname = module.substr(0,4);
if(module == "evmgr") { string key;
key = sn; if(module == "evmgr") {
}else { key = sn;
if(modname == "evml") { }else {
modname = "evml:" + module.substr(4, module.size()); if(modname == "evml") {
}else{ modname = "evml:" + module.substr(4, module.size());
modname = module; }else{
} modname = module;
}
key = this->configMap.at(sn + ":" + modname); key = this->configMap.at(sn + ":" + modname);
} spdlog::debug("key: ", key);
if(!key.empty()) {
json config;
int iret = LVDB::getLocalConfig(config, key);
if(iret < 0) {
ret["code"] = 1;
ret["msg"] = "evcloud failed to get config with k, v:" + key + " " + this->configMap[key].get<string>();
spdlog::error(ret["msg"].get<string>());
}else{
ret["data"] = config["data"];
ret["lastupdated"] = config["lastupdated"];
} }
}else{
ret["code"] = 1; if(!key.empty()) {
ret["msg"] = "no config for sn " + sn + ", module " + module; json config;
} int iret = LVDB::getLocalConfig(config, key);
if(iret < 0) {
ret["code"] = 1;
ret["msg"] = "evcloud failed to get config with key: " + key ;
spdlog::error(ret["msg"].get<string>());
}else{
ret["data"] = config["data"];
ret["lastupdated"] = config["lastupdated"];
}
}else{
ret["code"] = 1;
ret["msg"] = "no config for sn " + sn + ", module " + module;
}
}catch(exception &e){
ret["code"] = -1;
ret["msg"] = string("evcloudsvc exception: ") + e.what();
spdlog::error(ret["msg"].get<string>());
}
} }
res.set_content(ret.dump(), "text/json"); res.set_content(ret.dump(), "text/json");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论