提交 350b4af2 authored 作者: blu's avatar blu

big refacting of communitation architect

上级 d889dd22
...@@ -52,6 +52,8 @@ class EvDaemon{ ...@@ -52,6 +52,8 @@ class EvDaemon{
// for zmq // for zmq
void *pRouterCtx = NULL, *pRouter = NULL; void *pRouterCtx = NULL, *pRouter = NULL;
void *pDealerCtx = NULL, *pDealer = NULL;
string cloudAddr = "tcp://127.0.0.1:5548";
/// tracking sub-systems: evmgr, evpuller, evpusher, evml*, evslicer etc. /// tracking sub-systems: evmgr, evpuller, evpusher, evml*, evslicer etc.
json mapSubSystems; json mapSubSystems;
...@@ -484,6 +486,20 @@ class EvDaemon{ ...@@ -484,6 +486,20 @@ class EvDaemon{
EvDaemon(){ EvDaemon(){
int ret = 0; int ret = 0;
// get sn of device
json info;
try{
LVDB::getSn(info);
}catch(exception &e) {
spdlog::error("evdaemon failed to get sn: {}", e.what());
exit(1);
}
spdlog::info("evdaemon boot \n{}",info.dump(4));
devSn = info["sn"];
char* strEnv = getenv("BOOTSTRAP"); char* strEnv = getenv("BOOTSTRAP");
if(strEnv != NULL && memcmp(strEnv, "false", 5) == 0) { if(strEnv != NULL && memcmp(strEnv, "false", 5) == 0) {
bBootstrap = false; bBootstrap = false;
...@@ -503,13 +519,26 @@ class EvDaemon{ ...@@ -503,13 +519,26 @@ class EvDaemon{
string addr = string("tcp://*:") + to_string(portRouter); string addr = string("tcp://*:") + to_string(portRouter);
// setup zmq // setup router
ret = zmqhelper::setupRouter(&pRouterCtx, &pRouter, addr); ret = zmqhelper::setupRouter(&pRouterCtx, &pRouter, addr);
if(ret < 0) { if(ret < 0) {
spdlog::error("evdaemon {} setup router: {}", this->devSn, addr); spdlog::error("evdaemon {} setup router: {}", this->devSn, addr);
exit(1); exit(1);
} }
// dealer port
strEnv = getenv("CLOUD_ADDR");
if(strEnv != NULL) {
cloudAddr = strEnv;
}
// setup dealer
ret = zmqhelper::setupDealer(&pDealerCtx, &pDealer, cloudAddr, devSn);
if(ret != 0) {
spdlog::error("evdaemon {} failed to setup dealer", devSn);
exit(1);
}
this->thIdMain = this_thread::get_id(); this->thIdMain = this_thread::get_id();
// setup msg processor // setup msg processor
...@@ -524,7 +553,7 @@ class EvDaemon{ ...@@ -524,7 +553,7 @@ class EvDaemon{
} }
}); });
thRouter.detach(); thRouter.detach();
//
/// peerId -> value /// peerId -> value
peerData["status"] = json(); peerData["status"] = json();
peerData["pids"] = json(); peerData["pids"] = json();
...@@ -541,9 +570,6 @@ void cleanup(int signal) { ...@@ -541,9 +570,6 @@ void cleanup(int signal) {
int main(){ int main(){
signal(SIGCHLD, cleanup); signal(SIGCHLD, cleanup);
//sigignore(SIGCHLD); //sigignore(SIGCHLD);
json info;
LVDB::getSn(info);
spdlog::info("evdaemon: \n{}",info.dump(4));
EvDaemon srv; EvDaemon srv;
srv.run(); srv.run();
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论