From ec3ccf5882c8a403177832831cc400354459ff2c Mon Sep 17 00:00:00 2001 From: amichelo <andrea.michelotti@lnf.infn.it> Date: Wed, 20 Oct 2021 22:11:32 +0200 Subject: [PATCH] fixed bug autostart US --- ChaosAgent/AgentRegister.cpp | 5 ++++- ChaosAgent/ChaosAgent.cpp | 12 ++++++++---- ChaosMetadataService/QueryDataMsgPSConsumer.cpp | 16 +++++++++------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ChaosAgent/AgentRegister.cpp b/ChaosAgent/AgentRegister.cpp index 2e5c3a9f1..703458af2 100644 --- a/ChaosAgent/AgentRegister.cpp +++ b/ChaosAgent/AgentRegister.cpp @@ -134,6 +134,7 @@ CDWUniquePtr AgentRegister::registrationACK(CDWUniquePtr ack_pack) { if(ack_pack->hasKey("agent_description") && ack_pack->isCDataWrapperValue("agent_description")) { ChaosUniquePtr<chaos::common::data::CDataWrapper> aget_desc_ser(ack_pack->getCSDataValue("agent_description")); + DBG<<"AGENT DESC:"<<aget_desc_ser->getJSONString(); agent_instance_sd_wrapper.deserialize(aget_desc_ser.get()); } break; @@ -246,9 +247,11 @@ void AgentRegister::timeout() { end = agent_instance_sd_wrapper().node_associated.end(); it != end; it++) { + DBG<<"Association:"<<it->associated_node_uid; chaos::common::data::CDWUniquePtr param=ChaosAgent::getInstance()->checkAndPrepareScript(*it); + /// - if(param.get()&&it->auto_start) { + if(it->auto_start) { INFO << CHAOS_FORMAT("Autostart node %1%", %it->associated_node_uid); LAUNCH_PROCESS(*it,param); if(it->keep_alive) { diff --git a/ChaosAgent/ChaosAgent.cpp b/ChaosAgent/ChaosAgent.cpp index 64c8e6485..69e633478 100644 --- a/ChaosAgent/ChaosAgent.cpp +++ b/ChaosAgent/ChaosAgent.cpp @@ -126,10 +126,6 @@ void ChaosAgent::start() { StartableService::startImplementation(HealtManager::getInstance(), "HealthManager", __PRETTY_FUNCTION__); ChaosCommon<ChaosAgent>::start(); agent_register.start(__PRETTY_FUNCTION__); -#ifndef OLD_PROCESS_MANAGEMENT - - procRestUtil->start(true); // start in background -#endif if (signal((int) SIGINT, ChaosAgent::signalHanlder) == SIG_ERR) { throw CException(-1, "Error registering SIGINT signal", __PRETTY_FUNCTION__); @@ -142,6 +138,14 @@ void ChaosAgent::start() { if (signal((int) SIGTERM, ChaosAgent::signalHanlder) == SIG_ERR) { throw CException(-3, "Error registering SIGTERM signal", __PRETTY_FUNCTION__); } + +#ifndef OLD_PROCESS_MANAGEMENT + DBG << " STARTING REST SERVER ON PORT:" << ChaosAgent::getInstance()->settings.restport; + + sleep(chaos::common::constants::HBTimersTimeoutinMSec/1000); + procRestUtil->start(true); // start in background +#endif + wait_close_semaphore.waitRaw(); #ifndef OLD_PROCESS_MANAGEMENT diff --git a/ChaosMetadataService/QueryDataMsgPSConsumer.cpp b/ChaosMetadataService/QueryDataMsgPSConsumer.cpp index 138cdf41b..8af977569 100644 --- a/ChaosMetadataService/QueryDataMsgPSConsumer.cpp +++ b/ChaosMetadataService/QueryDataMsgPSConsumer.cpp @@ -180,14 +180,16 @@ while(attempt--){ DBG <<"] Found " << nodes.size()<< " to subscribe"; for(std::vector<std::string>::iterator i=nodes.begin();i!=nodes.end();i++){ - DBG <<"] Subscribing to:" << *i; + if(i->size()){ + DBG <<"] Subscribing to:" << *i; - if (cons->subscribe(*i) != 0) { - ERR <<" cannot subscribe to :" << *i<<" err:"<<cons->getLastError(); - - } else { - DBG <<"] Subscribed to:" << *i; - + if (cons->subscribe(*i) != 0) { + ERR <<" cannot subscribe to :" << *i<<" err:"<<cons->getLastError(); + + } else { + DBG <<"] Subscribed to:" << *i; + + } } } } -- GitLab