allow to specify how many times we can try to connect to the database at startup
add config options: db_startup_connection_max_attempts - default 0 (infinite) db_startup_connection_attempt_delay - delay in seconds between attempts (default 5) BREAKING CHANGE: WINIX_PLUGIN_INIT plugin message requires to set result status, you have to set the result status to true (env.res) if your plugin was initialized correctly, otherwise winix will not start
This commit is contained in:
@@ -70,7 +70,7 @@ sigset_t set;
|
||||
|
||||
|
||||
|
||||
void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
|
||||
bool ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
|
||||
{
|
||||
thread_tab.emplace_back();
|
||||
ThreadItem & item = thread_tab.back();
|
||||
@@ -96,7 +96,14 @@ void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
|
||||
|
||||
data.postgresql_connector.set_logger(item.object->get_logger());
|
||||
data.postgresql_connector.set_log_queries(config->log_db_query);
|
||||
data.postgresql_connector.wait_for_connection();
|
||||
|
||||
if( !data.postgresql_connector.wait_for_connection(config->db_startup_connection_max_attempts, config->db_startup_connection_attempt_delay) )
|
||||
{
|
||||
Log * plog = item.object->get_logger();
|
||||
(*plog) << logsave;
|
||||
return false;
|
||||
}
|
||||
|
||||
data.model_connector.set_db_connector(data.postgresql_connector);
|
||||
data.model_connector.set_flat_connector(data.json_connector);
|
||||
data.model_connector.set_logger(item.object->get_logger());
|
||||
@@ -125,23 +132,26 @@ void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name)
|
||||
log << log4 << "TM: added a thread to the queue, number: " << (thread_tab.size()-1)
|
||||
<< ", name: " << thread_name << logend;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::Add(BaseThread & pbase, const wchar_t * thread_name)
|
||||
bool ThreadManager::Add(BaseThread & pbase, const wchar_t * thread_name)
|
||||
{
|
||||
Add(&pbase, thread_name);
|
||||
return Add(&pbase, thread_name);
|
||||
}
|
||||
|
||||
|
||||
void ThreadManager::Add(BaseThread * pbase, const std::wstring & thread_name)
|
||||
bool ThreadManager::Add(BaseThread * pbase, const std::wstring & thread_name)
|
||||
{
|
||||
Add(pbase, thread_name.c_str());
|
||||
return Add(pbase, thread_name.c_str());
|
||||
}
|
||||
|
||||
void ThreadManager::Add(BaseThread & pbase, const std::wstring & thread_name)
|
||||
|
||||
bool ThreadManager::Add(BaseThread & pbase, const std::wstring & thread_name)
|
||||
{
|
||||
Add(&pbase, thread_name.c_str());
|
||||
return Add(&pbase, thread_name.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user