mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 04:34:16 +01:00
fix: terminate process if service unload fails
This commit is contained in:
parent
880095428c
commit
b80681e3e1
1 changed files with 17 additions and 2 deletions
|
|
@ -156,6 +156,8 @@ public sealed class EntryPoint
|
||||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
||||||
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
|
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
|
||||||
|
|
||||||
|
var unloadFailed = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (info.DelayInitializeMs > 0)
|
if (info.DelayInitializeMs > 0)
|
||||||
|
|
@ -180,9 +182,17 @@ public sealed class EntryPoint
|
||||||
|
|
||||||
dalamud.WaitForUnload();
|
dalamud.WaitForUnload();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
ServiceManager.UnloadAllServices();
|
ServiceManager.UnloadAllServices();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Fatal(ex, "Could not unload services.");
|
||||||
|
unloadFailed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Fatal(ex, "Unhandled exception on main thread.");
|
Log.Fatal(ex, "Unhandled exception on main thread.");
|
||||||
}
|
}
|
||||||
|
|
@ -195,6 +205,11 @@ public sealed class EntryPoint
|
||||||
Log.CloseAndFlush();
|
Log.CloseAndFlush();
|
||||||
SerilogEventSink.Instance.LogLine -= SerilogOnLogLine;
|
SerilogEventSink.Instance.LogLine -= SerilogOnLogLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we didn't unload services correctly, we need to kill the process.
|
||||||
|
// We will never signal to Framework.
|
||||||
|
if (unloadFailed)
|
||||||
|
Environment.Exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SerilogOnLogLine(object? sender, (string Line, LogEvent LogEvent) ev)
|
private static void SerilogOnLogLine(object? sender, (string Line, LogEvent LogEvent) ev)
|
||||||
|
|
@ -327,7 +342,7 @@ public sealed class EntryPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
var pluginInfo = string.Empty;
|
var pluginInfo = string.Empty;
|
||||||
var supportText = ", please visit us on Discord for more help.";
|
var supportText = ", please visit us on Discord for more help";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pm = Service<PluginManager>.GetNullable();
|
var pm = Service<PluginManager>.GetNullable();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue