From 2cf03d4b6894f1d8dc2c53898fadcf28d1c7cac9 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Mon, 29 Apr 2024 16:16:25 +0200 Subject: [PATCH] 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 --- Moonlight/Program.cs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Moonlight/Program.cs b/Moonlight/Program.cs index 2b40ca7..3561037 100644 --- a/Moonlight/Program.cs +++ b/Moonlight/Program.cs @@ -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);