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
This commit is contained in:
Melanie
2009-08-19 04:39:02 +01:00
parent d95d3b949b
commit 99c7a43ffd
4 changed files with 81 additions and 1 deletions

View File

@@ -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)
{
}
}
}
}