Add retry of start method for poll as well as async plugins
@@ -387,21 +387,47 @@ void SouthService::start(string& coreAddress, unsigned short corePort)
const char *pluginInterfaceVer = southPlugin->getInfo()->interface;
bool pollInterfaceV2 = (pluginInterfaceVer[0]=='2' && pluginInterfaceVer[1]=='.');
logger->info("pollInterfaceV2=%s", pollInterfaceV2?"true":"false");
+
+ /*
+ * Start the plugin. If it fails with an excpetion retry the start with a delay
+ * That delay starts at 500mS and will backoff to 1 minute
+ *
+ * We will continue to retry the start until the service is shutdown
+ */
+ bool started = false;
+ int delay = 500;
+ while (started == false && m_shutdown == false)
+ {
if (southPlugin->persistData())
{
Logger::getLogger()->debug("Plugin persists data");
string pluginData = m_pluginData->loadStoredData(m_dataKey);
+ try {
southPlugin->startData(pluginData);
+ started = true;
+ } catch (...) {
+ Logger::getLogger()->debug("Plugin start raised an exception");
+ }
}
else
{
Logger::getLogger()->debug("Plugin does not persist data");
try {
southPlugin->start();
+ started = true;
} catch (...) {
Logger::getLogger()->debug("Plugin start raised an exception");
}
}
+ if (!started)
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(delay));
+ if (delay < 60 * 1000) // Backoff the delay to 1 minute
+ {
+ delay *= 2;
+ }
+ }
+ }
while (!m_shutdown)
{
