Factor out common registration of "show uptime" command

0.7.4-extended
Justin Clark-Casey (justincc) 2012-11-22 04:11:03 +00:00
parent 08234d0097
commit 632dad337b
3 changed files with 80 additions and 73 deletions

View File

@ -118,8 +118,9 @@ namespace OpenSim.Framework.Servers
/// </summary>
protected virtual void StartupSpecific()
{
if (m_console != null)
{
if (m_console == null)
return;
ILoggerRepository repository = LogManager.GetRepository();
IAppender[] appenders = repository.GetAppenders();
@ -148,6 +149,8 @@ namespace OpenSim.Framework.Servers
Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
}
RegisterCommonCommands();
m_console.Commands.AddCommand("General", false, "quit",
"quit",
"Quit the application", HandleQuit);
@ -168,10 +171,6 @@ namespace OpenSim.Framework.Servers
"show threads",
"Show thread status", HandleShow);
m_console.Commands.AddCommand("General", false, "show uptime",
"show uptime",
"Show server uptime", HandleShow);
m_console.Commands.AddCommand("General", false, "show version",
"show version",
"Show server version", HandleShow);
@ -190,7 +189,6 @@ namespace OpenSim.Framework.Servers
"Manually invoke runtime garbage collection. For debugging purposes",
HandleForceGc);
}
}
private void HandleForceGc(string module, string[] args)
{

View File

@ -49,6 +49,18 @@ namespace OpenSim.Framework.Servers
m_startuptime = DateTime.Now;
}
/// <summary>
/// Register common commands once m_console has been set if it is going to be set
/// </summary>
public void RegisterCommonCommands()
{
if (m_console == null)
return;
m_console.Commands.AddCommand(
"General", false, "show uptime", "show uptime", "Show server uptime", HandleShow);
}
public virtual void HandleShow(string module, string[] cmd)
{
List<string> args = new List<string>(cmd);

View File

@ -239,6 +239,8 @@ namespace OpenSim.Server.Base
CreatePIDFile(startupConfig.GetString("PIDFile"));
}
RegisterCommonCommands();
// Register the quit command
//
MainConsole.Instance.Commands.AddCommand("General", false, "quit",
@ -254,11 +256,6 @@ namespace OpenSim.Server.Base
"command-script <script>",
"Run a command script from file", HandleScript);
MainConsole.Instance.Commands.AddCommand("General", false, "show uptime",
"show uptime",
"Show server uptime", HandleShow);
// Allow derived classes to perform initialization that
// needs to be done after the console has opened
//