MXS-2481 Ensure directory exists before creating db

This commit is contained in:
Johan Wikman 2019-05-23 14:43:38 +03:00
parent 8a2c43d297
commit 8204c5099b

View File

@ -146,6 +146,10 @@ sqlite3* open_or_create_db(const std::string& path)
{
MXS_ERROR("Opening/creating the sqlite3 database %s failed: %s",
path.c_str(), sqlite3_errstr(rv));
MXS_ERROR("Could not open sqlite3 database for storing information "
"about dynamically detected Clustrix nodes. The Clustrix "
"monitor will remain dependant upon statically defined "
"bootstrap nodes.");
}
return pDb;
@ -170,20 +174,21 @@ ClustrixMonitor* ClustrixMonitor::create(const string& name, const string& modul
path += "/";
path += name;
if (!mxs_mkdir_all(path.c_str(), 0744))
{
MXS_ERROR("Could not create the directory %s, MaxScale will not be "
"able to create database for persisting connection "
"information of dynamically detected Clustrix nodes.",
path.c_str());
}
path += "/clustrix_nodes-v";
path += std::to_string(SCHEMA_VERSION);
path += ".db";
sqlite3* pDb = open_or_create_db(path);
if (!pDb)
{
MXS_WARNING("Could not open sqlite3 database for storing information "
"about dynamically detected Clustrix nodes. The Clustrix "
"monitor will remain dependant upon statically defined "
"bootstrap nodes.");
}
return new ClustrixMonitor(name, module, pDb);
}