Mercurial > hg > orthanc-databases
diff Framework/Common/DatabaseManager.cpp @ 141:0b3e9ee53c46
Added 'MaximumConnectionRetries' & 'ConnectionRetryInterval' to configure the retries when connecting to the DB at startup
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Mon, 03 Feb 2020 22:29:51 +0100 |
parents | 4cd7e45b671e |
children | 063aa53b5917 |
line wrap: on
line diff
--- a/Framework/Common/DatabaseManager.cpp Fri Jan 31 17:24:29 2020 +0100 +++ b/Framework/Common/DatabaseManager.cpp Mon Feb 03 22:29:51 2020 +0100 @@ -32,9 +32,11 @@ { IDatabase& DatabaseManager::GetDatabase() { - static const unsigned int MAX_CONNECTION_ATTEMPTS = 10; // TODO: Parameter + unsigned int maxConnectionRetries = 10; + unsigned int connectionRetryInterval = 5; + unsigned int count = 0; - unsigned int count = 0; + factory_->GetConnectionRetriesParameters(maxConnectionRetries, connectionRetryInterval); while (database_.get() == NULL) { @@ -50,10 +52,10 @@ { count ++; - if (count <= MAX_CONNECTION_ATTEMPTS) + if (count <= maxConnectionRetries) { LOG(WARNING) << "Database is currently unavailable, retrying..."; - boost::this_thread::sleep(boost::posix_time::seconds(1)); + boost::this_thread::sleep(boost::posix_time::seconds(connectionRetryInterval)); continue; } else