From 4d1536f1ecde8ed03e1f2e69f45207eb9dddfa7c Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Mon, 12 Dec 2016 00:07:36 +0000
Subject: Allow OpenSim to respond to Unix signals. This may need work to be
properly ignoed on Windows. Windows devs, please test and check for platform
flags if this causes issues in Windows
---
OpenSim/Region/Application/OpenSim.cs | 25 +++++++++++++++++++++++--
bin/Mono.Posix.dll | Bin 0 -> 207872 bytes
prebuild.xml | 1 +
3 files changed, 24 insertions(+), 2 deletions(-)
create mode 100755 bin/Mono.Posix.dll
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index cf2bf33..203fe5e 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -26,6 +26,7 @@
*/
using System;
+using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
@@ -74,7 +75,7 @@ namespace OpenSim
private string m_timedScript = "disabled";
private int m_timeInterval = 1200;
- private Timer m_scriptTimer;
+ private System.Timers.Timer m_scriptTimer;
public OpenSim(IConfigSource configSource) : base(configSource)
{
@@ -125,6 +126,25 @@ namespace OpenSim
m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod);
}
+ private static Mono.Unix.UnixSignal[] signals = new Mono.Unix.UnixSignal[]
+ {
+// new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGINT),
+ new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM)
+ };
+
+ private Thread signal_thread = new Thread (delegate ()
+ {
+ System.Console.WriteLine("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
+ while (true)
+ {
+ // Wait for a signal to be delivered
+ int index = Mono.Unix.UnixSignal.WaitAny (signals, -1);
+
+ //Mono.Unix.Native.Signum signal = signals [index].Signum;
+ MainConsole.Instance.RunCommand("shutdown");
+ }
+ });
+
///
/// Performs initialisation of the scene, such as loading configuration from disk.
///
@@ -134,6 +154,7 @@ namespace OpenSim
m_log.Info("========================= STARTING OPENSIM =========================");
m_log.Info("====================================================================");
+ signal_thread.Start();
//m_log.InfoFormat("[OPENSIM MAIN]: GC Is Server GC: {0}", GCSettings.IsServerGC.ToString());
// http://msdn.microsoft.com/en-us/library/bb384202.aspx
//GCSettings.LatencyMode = GCLatencyMode.Batch;
@@ -217,7 +238,7 @@ namespace OpenSim
// Start timer script (run a script every xx seconds)
if (m_timedScript != "disabled")
{
- m_scriptTimer = new Timer();
+ m_scriptTimer = new System.Timers.Timer();
m_scriptTimer.Enabled = true;
m_scriptTimer.Interval = m_timeInterval*1000;
m_scriptTimer.Elapsed += RunAutoTimerScript;
diff --git a/bin/Mono.Posix.dll b/bin/Mono.Posix.dll
new file mode 100755
index 0000000..97ec8bf
Binary files /dev/null and b/bin/Mono.Posix.dll differ
diff --git a/prebuild.xml b/prebuild.xml
index 2bb053e..cb39e18 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1790,6 +1790,7 @@
+
--
cgit v1.1