Bläddra i källkod

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
Marcel Baumgartner 1 år sedan
förälder
incheckning
2cf03d4b68
1 ändrade filer med 24 tillägg och 5 borttagningar
  1. 24 5
      Moonlight/Program.cs

+ 24 - 5
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);