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

big refacting of communitation architect

上级 8fb4f287
...@@ -26,6 +26,9 @@ using namespace httplib; ...@@ -26,6 +26,9 @@ using namespace httplib;
using namespace nlohmann; using namespace nlohmann;
using namespace zmqhelper; using namespace zmqhelper;
#define EV_FILE_LVDB_DAEMON "/opt/lvl/daemon"
class EvDaemon{ class EvDaemon{
private: private:
Server svr; Server svr;
...@@ -336,6 +339,8 @@ class EvDaemon{ ...@@ -336,6 +339,8 @@ class EvDaemon{
ret = z_send_multiple(pRouter, v); ret = z_send_multiple(pRouter, v);
if(ret < 0) { if(ret < 0) {
spdlog::error("evdaemon {} failed to send multiple: {}", devSn, zmq_strerror(zmq_errno())); spdlog::error("evdaemon {} failed to send multiple: {}", devSn, zmq_strerror(zmq_errno()));
}else{
spdlog::info("evdaemon {} cached msg sent from {} to {} of type: {}, content: {}", body2str(v[1]), body2str(v[0]), body2str(v[2]), body2str(v[3]));
} }
} }
} }
...@@ -379,6 +384,10 @@ class EvDaemon{ ...@@ -379,6 +384,10 @@ class EvDaemon{
this->config = data; this->config = data;
this->bReload = true; this->bReload = true;
spdlog::info("evdaemon {} received cloud config diff:\n{}\nnew\n{}", devSn, this->deltaCfg.dump(4), data.dump()); spdlog::info("evdaemon {} received cloud config diff:\n{}\nnew\n{}", devSn, this->deltaCfg.dump(4), data.dump());
ret = LVDB::setLocalConfig(data, "", EV_FILE_LVDB_DAEMON);
if(ret < 0) {
spdlog::error("evdameon {} failed to save new config to local db: {}", devSn, data.dump());
}
// TODO: detailed diff on submodules // TODO: detailed diff on submodules
}else{ }else{
spdlog::info("evdaemon {} received same configuration and ignored: {}", devSn, data.dump()); spdlog::info("evdaemon {} received same configuration and ignored: {}", devSn, data.dump());
...@@ -476,7 +485,8 @@ class EvDaemon{ ...@@ -476,7 +485,8 @@ class EvDaemon{
EvDaemon(){ EvDaemon(){
int ret = 0; int ret = 0;
string dir_ = string("mkdir -p") + EV_FILE_LVDB_DAEMON;
system(dir_.c_str());
// get sn of device // get sn of device
json info; json info;
try{ try{
...@@ -501,6 +511,14 @@ class EvDaemon{ ...@@ -501,6 +511,14 @@ class EvDaemon{
port = stoi(strEnv); port = stoi(strEnv);
} }
json cfg;
ret = LVDB::getLocalConfig(cfg, "", EV_FILE_LVDB_DAEMON);
if(ret < 0) {
spdlog::info("evdameon {} no local config", devSn, cfg.dump());
}else{
this->config = cfg;
}
// zmq router port // zmq router port
strEnv = getenv("ROUTER_PORT"); strEnv = getenv("ROUTER_PORT");
if(strEnv != nullptr) { if(strEnv != nullptr) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论