From 99c7a43ffdb9c3b4dee984f7cd788742c6ee3e53 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Aug 2009 04:39:02 +0100 Subject: Add rest console support to the user server. Will ask new questions at startup. To use, run it normally once, answering the questions, then run again with -console=rest. Also now supports -console=basic for a console that reads stdin --- OpenSim/Server/Base/ServicesServerBase.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'OpenSim/Server/Base/ServicesServerBase.cs') diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index 619c2d1..1d9eb0d 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs @@ -65,6 +65,10 @@ namespace OpenSim.Server.Base // private bool m_Running = true; + // PID file + // + private string m_pidFile = String.Empty; + // Handle all the automagical stuff // public ServicesServerBase(string prompt, string[] args) @@ -211,6 +215,11 @@ namespace OpenSim.Server.Base } } + if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) + { + CreatePIDFile(startupConfig.GetString("PIDFile")); + } + // Register the quit command // MainConsole.Instance.Commands.AddCommand("base", false, "quit", @@ -230,6 +239,8 @@ namespace OpenSim.Server.Base MainConsole.Instance.Prompt(); } + if (m_pidFile != String.Empty) + File.Delete(m_pidFile); return 0; } @@ -246,5 +257,22 @@ namespace OpenSim.Server.Base protected virtual void Initialise() { } + + protected void CreatePIDFile(string path) + { + try + { + string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); + FileStream fs = File.Create(path); + System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + Byte[] buf = enc.GetBytes(pidstring); + fs.Write(buf, 0, buf.Length); + fs.Close(); + m_pidFile = path; + } + catch (Exception) + { + } + } } } -- cgit v1.1