From 14d6d6f7a5c9da0dada36a4624325fb030db799a Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 11 Jan 2017 23:05:06 +0000 Subject: [PATCH] Also add the ability to quit on SIGTERM for ROBUST --- OpenSim/Server/Base/ServicesServerBase.cs | 36 +++++++++++++++++++++++ prebuild.xml | 1 + 2 files changed, 37 insertions(+) diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index f60b5fb6dc..d151de663e 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -61,6 +61,9 @@ namespace OpenSim.Server.Base // private bool m_Running = true; + private static Mono.Unix.UnixSignal[] signals; + + // Handle all the automagical stuff // public ServicesServerBase(string prompt, string[] args) : base() @@ -183,6 +186,39 @@ namespace OpenSim.Server.Base RegisterCommonCommands(); RegisterCommonComponents(Config); + Thread signal_thread = new Thread (delegate () + { + 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; + ShutdownSpecific(); + m_Running = false; + Environment.Exit(0); + } + }); + + if(!Util.IsWindows()) + { + try + { + // linux mac os specifics + signals = new Mono.Unix.UnixSignal[] + { + new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM) + }; + signal_thread.Start(); + } + catch (Exception e) + { + m_log.Info("Could not set up UNIX signal handlers. SIGTERM will not"); + m_log.InfoFormat("shut down gracefully: {0}", e.Message); + m_log.Debug("Exception was: ", e); + } + } + // Allow derived classes to perform initialization that // needs to be done after the console has opened Initialise(); diff --git a/prebuild.xml b/prebuild.xml index cb39e18e16..fddbca3286 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -497,6 +497,7 @@ +