Also add the ability to quit on SIGTERM for ROBUST

melanie
Melanie Thielker 2017-01-11 23:05:06 +00:00
parent d96bcd8264
commit 14d6d6f7a5
2 changed files with 37 additions and 0 deletions

View File

@ -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();

View File

@ -497,6 +497,7 @@
<Reference name="OpenSim.Framework.Monitoring"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="Mono.Posix" path="../../../bin/"/>
<Reference name="Nini" path="../../../bin/"/>
<Reference name="log4net" path="../../../bin/"/>