Improved MySQL container boot handling

This will reduce the large error messages to a single line saying that the mysql container is still booting. Hopefully this fixes the login cli command as well
This commit is contained in:
Marcel Baumgartner 2024-04-29 16:16:25 +02:00
parent 52bab229ea
commit 2cf03d4b68

View file

@ -6,6 +6,7 @@ using Moonlight.Core.Configuration;
using Moonlight.Core.Database;
using Moonlight.Core.Http.Middleware;
using Moonlight.Core.Services;
using MySqlConnector;
// Create needed storage directories
Directory.CreateDirectory(PathBuilder.Dir("storage"));
@ -74,11 +75,29 @@ await featureService.Load();
var pluginService = new PluginService();
await pluginService.Load();
// Check database migrations
await DatabaseCheckHelper.Check(
new DataContext(configService),
false
);
try
{
// Check database migrations
await DatabaseCheckHelper.Check(
new DataContext(configService),
false
);
}
catch (MySqlException e)
{
if (e.InnerException is EndOfStreamException eosException)
{
if (eosException.Message.Contains("read 4 header bytes"))
{
Logger.Warn("The mysql server appears to be still booting up. Exiting...");
Environment.Exit(1);
return;
}
}
throw;
}
// Add pre constructed services
builder.Services.AddSingleton(featureService);