提交 7d1a8b8f authored 作者: blu's avatar blu

cloud cmd api for platform client

上级 3c595cf3
......@@ -187,20 +187,20 @@ private:
std::lock_guard<std::mutex> lock(mutSubsystem);
if(subs.size() != 0) {
for(auto &k: subs) {
if((this->peerData["status"].count(k) == 0 || this->peerData["status"][k] == 0) && this->peerData["config"].count(k) != 0 && this->peerData["enabled"].count(k) != 0 && this->peerData["enabled"][k] != 0) {
if((this->peerData["status"].count(k) == 0 || this->peerData["status"][k] == 0 || this->peerData["status"][k] != -2) && this->peerData["config"].count(k) != 0 && this->peerData["enabled"].count(k) != 0 && this->peerData["enabled"][k] != 0) {
pid_t pid;
ret = zmqhelper::forkSubsystem(devSn, k, portRouter, pid);
if(0 == ret) {
this->peerData["status"][k] = 0;
this->peerData["pids"][k] = pid;
spdlog::info("evdaemon {} created subsystem {}", this->devSn, k);
spdlog::info("evdaemon {} created subsystem {} (current status: {})", this->devSn, k, this->peerData["status"][k].get<int>());
}
else {
spdlog::info("evdaemon {} failed to create subsystem {}", this->devSn, k);
}
}
else {
spdlog::warn("evdaemon {} refuse to start subsystem {}, maybe it's disabled", this->devSn, k);
spdlog::warn("evdaemon {} refuse to start subsystem {}, maybe it's disabled or removed out from lastes cluster config", this->devSn, k);
}
}
}
......@@ -297,11 +297,14 @@ private:
for(auto &[k,v]: mods.items()) {
spdlog::info("evdaemon {} startSubSystems config diff to module action: {} -> {}", this->devSn, string(k), int(v));
if(v == 0) {
// stop
this->peerData["status"][k] = -2; // stopped
sendCmd2Peer(k, EV_MSG_META_VALUE_CMD_STOP, "0");
}
else if(int(v) == 1 || int(v) == 2) {
int status = (this->peerData["status"].count(k) == 0) ? -1:this->peerData["status"][k].get<int>();
spdlog::info("evdaemon module {} status {}", this->devSn, k, status);
spdlog::info("evdaemon {} module {} status {}", this->devSn, k, status);
if(this->peerData["status"].count(k) == 0 || this->peerData["status"][k] == 0||this->peerData["status"][k] == -1) {
pid_t pid;
spdlog::info("evdaemon {} starting subsystem {}", this->devSn, k);
......@@ -378,6 +381,9 @@ private:
spdlog::info("evdaemon {} peer {} config sent: {}", devSn,selfId, cfg);
}
else {
if(peerData["status"][selfId] == -2){
spdlog::warn("evdaemon {} refuse to start {}: it was asked to be stopped, and is removed from cluster config", this->devSn, selfId);
}else{
peerData["status"][selfId] = 0;
if(peerData["pids"].count(selfId) != 0) {
peerData["pids"].erase(selfId);
......@@ -390,6 +396,7 @@ private:
spdlog::warn("evdaemon {} peer {} disconnected. won't restart it since BOOTSTRAP=false", devSn, selfId);
}
}
}
// event
json jEvt;
......
......@@ -186,7 +186,7 @@ error_exit:
return -1;
}
json *mod = LVDB::findConfigModule(config, sp[0], sp[1], stoi(sp[2]));
if(mod == nullptr||peerData["status"].count(selfId) == 0) {
if(mod == nullptr) {
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;
}
......@@ -358,6 +358,8 @@ public:
exit(1);
}
spdlog::info("evmgr {} boot", devSn);
//
string addr = string("tcp://127.0.0.1:") + drport;;
ident = devSn + ":evmgr:0";
......
......@@ -791,6 +791,8 @@ public:
exit(1);
}
spdlog::info("evmlmotio {} boot", selfId);
//
string addr = string("tcp://127.0.0.1:") + drport;
int ret = zmqhelper::setupDealer(&pDaemonCtx, &pDaemon, addr, selfId);
......
......@@ -430,6 +430,8 @@ public:
exit(1);
}
spdlog::info("evpuller {} boot", selfId);
//
string addr = string("tcp://127.0.0.1:") + drport;
int ret = zmqhelper::setupDealer(&pDaemonCtx, &pDaemon, addr, selfId);
......
......@@ -504,6 +504,8 @@ public:
exit(1);
}
spdlog::info("evpusher {} boot", selfId);
//
string addr = string("tcp://127.0.0.1:") + drport;
int ret = zmqhelper::setupDealer(&pDaemonCtx, &pDaemon, addr, selfId);
......
......@@ -939,6 +939,8 @@ public:
exit(1);
}
spdlog::info("evslicer {} boot", selfId);
//
string addr = string("tcp://127.0.0.1:") + drport;
int ret = zmqhelper::setupDealer(&pDaemonCtx, &pDaemon, addr, selfId);
......
......@@ -421,8 +421,10 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
string oldSn = oldMod["sn"];
string newSn = newMod["sn"];
if(oldSn != newSn) {
string oldGid = sn + ":" + modName + ":" + to_string(oldMod["iid"].get<int>());
string oldGid = oldSn + ":" + modName + ":" + to_string(oldMod["iid"].get<int>());
string newGid = newSn + ":" + modName + ":" + to_string(newMod["iid"].get<int>());
if(oldGid != newGid) {
ret["data"][oldGid] = 0;
}
......@@ -430,9 +432,6 @@ json getModulesOperFromConfDiff(json& oldConfig, json &newConfig, json &diff, st
continue;
}
string oldGid = oldSn + ":" + modName + ":" + to_string(oldMod["iid"].get<int>());
string newGid = newSn + ":" + modName + ":" + to_string(newMod["iid"].get<int>());
if(propName == "enabled") {
if(newMod.count("enabled") == 0||newMod["enabled"].get<int>() == 0) {
ret["data"][newGid] = 0;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论