Added a check for the DB and a delay at start up if the database is not available (#148)

This commit is contained in:
Michael Green
2023-10-08 22:34:59 -07:00
committed by GitHub
parent 1934558595
commit f9d6cc4bdc
2 changed files with 43 additions and 1 deletions

View File

@@ -12,8 +12,24 @@ using Microsoft.OpenApi.Models;
Logging.WriteToDiskOnly = true;
Logging.Log(Logging.LogType.Information, "Startup", "Starting Gaseous Server " + Assembly.GetExecutingAssembly().GetName().Version);
// set up db
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
// check db availability
bool dbOnline = false;
do
{
Logging.Log(Logging.LogType.Information, "Startup", "Waiting for database...");
if (db.TestConnection() == true)
{
dbOnline = true;
}
else
{
Thread.Sleep(30000);
}
} while (dbOnline == true);
// set up db
db.InitDB();
// load app settings