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

View File

@ -46,6 +46,8 @@ namespace OpenSim.Framework
public bool HttpSSL = ConfigSettings.DefaultUserServerHttpSSL;
public uint DefaultUserLevel = 0;
public string LibraryXmlfile = "";
public string ConsoleUser = String.Empty;
public string ConsolePass = String.Empty;
private Uri m_inventoryUrl;
@ -155,6 +157,12 @@ namespace OpenSim.Framework
m_configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Minimum Level a user should have to login [0 default]", "0", false);
m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Remote console access user name [Default: disabled]", "0", false);
m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Remote console access password [Default: disabled]", "0", false);
}
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@ -209,6 +217,12 @@ namespace OpenSim.Framework
case "library_location":
LibraryXmlfile = (string)configuration_result;
break;
case "console_user":
ConsoleUser = (string)configuration_result;
break;
case "console_pass":
ConsolePass = (string)configuration_result;
break;
}
return true;

View File

@ -43,6 +43,7 @@ using OpenSim.Framework.Statistics;
using OpenSim.Grid.Communications.OGS1;
using OpenSim.Grid.Framework;
using OpenSim.Grid.UserServer.Modules;
using Nini.Config;
namespace OpenSim.Grid.UserServer
{
@ -73,8 +74,22 @@ namespace OpenSim.Grid.UserServer
protected AvatarCreationModule m_appearanceModule;
protected static string m_consoleType = "local";
protected static IConfigSource m_config = null;
public static void Main(string[] args)
{
ArgvConfigSource argvSource = new ArgvConfigSource(args);
argvSource.AddSwitch("Startup", "console", "c");
IConfig startupConfig = argvSource.Configs["Startup"];
if (startupConfig != null)
{
m_consoleType = startupConfig.GetString("console", "local");
}
m_config = argvSource;
XmlConfigurator.Configure();
m_log.Info("Launching UserServer...");
@ -87,7 +102,18 @@ namespace OpenSim.Grid.UserServer
public OpenUser_Main()
{
m_console = new LocalConsole("User");
switch (m_consoleType)
{
case "rest":
m_console = new RemoteConsole("User");
break;
case "basic":
m_console = new CommandConsole("User");
break;
default:
m_console = new LocalConsole("User");
break;
}
MainConsole.Instance = m_console;
}
@ -129,6 +155,17 @@ namespace OpenSim.Grid.UserServer
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
if (m_console is RemoteConsole)
{
System.Console.WriteLine("Initialized REST console");
RemoteConsole c = (RemoteConsole)m_console;
c.SetServer(m_httpServer);
IConfig netConfig = m_config.AddConfig("Network");
netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
netConfig.Set("ConsolePass", Cfg.ConsolePass);
c.ReadConfig(m_config);
}
RegisterInterface<CommandConsole>(m_console);
RegisterInterface<UserConfig>(Cfg);

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

View File

@ -1178,6 +1178,7 @@
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="XMLRPC.dll"/>
<Reference name="log4net.dll"/>
<Reference name="Nini.dll"/>
<Reference name="DotNetOpenId.dll"/>
<Files>