Re-introduce SIGTERM signal handling

According to the .NET 6/8 docs, this is handled on Windows as well
This commit is contained in:
lickx
2024-11-02 12:59:56 +01:00
parent 825b1f7f98
commit 68eb1595ac
2 changed files with 20 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Timers;
using System.Net;
using System.Runtime.InteropServices;
using log4net;
using NDesk.Options;
using Nini.Config;
@@ -79,6 +80,7 @@ namespace OpenSim
private string m_timedScript = "disabled";
private int m_timeInterval = 1200;
private System.Timers.Timer m_scriptTimer;
private PosixSignalRegistration m_signalReg;
public OpenSim(IConfigSource configSource) : base(configSource)
{
@@ -132,6 +134,12 @@ namespace OpenSim
m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod);
m_log.InfoFormat("[OPENSIM MAIN] Running GC in {0} mode", GCSettings.IsServerGC ? "server":"workstation");
m_signalReg = PosixSignalRegistration.Create(PosixSignal.SIGTERM, context =>
{
m_log.Info("Received SIGTERM, shutting down");
MainConsole.Instance.RunCommand("shutdown");
});
}
/// <summary>
@@ -1520,5 +1528,7 @@ namespace OpenSim
result = result.TrimEnd(' ');
return result;
}
}
}

View File

@@ -32,6 +32,7 @@ using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Collections.Generic;
using OpenSim.Framework;
@@ -50,6 +51,7 @@ namespace OpenSim.Server
protected static List<IServiceConnector> m_ServiceConnectors = new();
protected static PluginLoader loader;
private static PosixSignalRegistration m_signalReg;
private static bool m_NoVerifyCertChain = false;
private static bool m_NoVerifyCertHostname = false;
@@ -95,13 +97,20 @@ namespace OpenSim.Server
Culture.SetCurrentCulture();
Culture.SetDefaultCurrentCulture();
m_signalReg = PosixSignalRegistration.Create(PosixSignal.SIGTERM, context =>
{
m_log.Info("Received SIGTERM, shutting down");
m_Server?.Shutdown();
Util.StopThreadPool();
});
ServicePointManager.DefaultConnectionLimit = 64;
ServicePointManager.MaxServicePointIdleTime = 30000;
ServicePointManager.Expect100Continue = false;
ServicePointManager.UseNagleAlgorithm = false;
ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
m_Server = new HttpServerBase("R.O.B.U.S.T.", args);
string registryLocation;