diff --git a/writeengine/client/we_clients.cpp b/writeengine/client/we_clients.cpp index 1badf9ab4..9ad4c046e 100644 --- a/writeengine/client/we_clients.cpp +++ b/writeengine/client/we_clients.cpp @@ -154,6 +154,22 @@ struct QueueShutdown x.shutdown(); } }; + +/** + + * This function checks if the WriteEngineServer (WES) is configured + * for the specified node in the configuration. + * @param config Pointer to the configuration object + * @param fOtherEnd The name of the node to check + * @return true if WES is configured, false otherwise + */ +bool isWESConfigured(config::Config* config, const std::string& fOtherEnd) +{ + // Check if WES IP address record exists in the config (if not, this is a read-only node) + std::string otherEndDnOrIPStr = config->getConfig(fOtherEnd, "IPAddr"); + return !(otherEndDnOrIPStr.empty() || otherEndDnOrIPStr == "unassigned"); +} + } // namespace namespace WriteEngine @@ -224,6 +240,13 @@ void WEClients::Setup() snprintf(buff, sizeof(buff), "pm%u_WriteEngineServer", moduleID); string fServer(buff); + // Check if WES is configured for this module + if (!isWESConfigured(rm->getConfig(), fServer)) + { + writeToLog(__FILE__, __LINE__, "Skipping WriteEngineServer client creation for " + fServer + " as the node is read-only", LOG_TYPE_INFO); + continue; + } + boost::shared_ptr cl(new MessageQueueClient(fServer, rm->getConfig())); boost::shared_ptr nl(new boost::mutex());