Add modular configuration for Robust connectors

We can provide modular ini for connectors...

    look for our configuration in the following places...
      1) in the default ini/-inifile
      2) in the named file (ConfigName) located in the configured directory
            (see Robust[.HG].ini [Start] section for ConfigDirectory)
      3) in the repository named in the connector (ConfigURL)
           In this case, the file will be written into the configured
           directory with the specified

  See example connector/service @ https://github.com/BlueWall/SlipStream
  for testing.
connector_plugin
BlueWall 2012-10-03 16:07:11 -04:00
parent 503ce70f74
commit 3e71c71cbf
5 changed files with 116 additions and 0 deletions

View File

@ -33,6 +33,7 @@ using System.Xml.Serialization;
using System.Text;
using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenMetaverse;
@ -333,5 +334,42 @@ namespace OpenSim.Server.Base
return ret;
}
public static IConfig GetConfig(string configFile, string configName)
{
IConfig config;
if (File.Exists(configFile))
{
IConfigSource configsource = new IniConfigSource(configFile);
config = configsource.Configs[configName];
}
else
config = null;
return config;
}
public static IConfigSource LoadInitialConfig(string url)
{
IConfigSource source = new XmlConfigSource();
m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url);
// The ini file path is a http URI
// Try to read it
try
{
XmlReader r = XmlReader.Create(url);
IConfigSource cs = new XmlConfigSource(r);
source.Merge(cs);
}
catch (Exception e)
{
m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url);
Environment.Exit(1);
}
return source;
}
}
}

View File

@ -64,6 +64,12 @@ namespace OpenSim.Server.Base
get { return m_Config; }
}
public string ConfigDirectory
{
get;
private set;
}
// Run flag
//
private bool m_Running = true;
@ -153,6 +159,8 @@ namespace OpenSim.Server.Base
startupConfig = m_Config.Configs["Startup"];
}
ConfigDirectory = startupConfig.GetString("ConfigDirectory", ".");
prompt = startupConfig.GetString("Prompt", prompt);
// Allow derived classes to load config before the console is

View File

@ -39,8 +39,69 @@ namespace OpenSim.Server.Handlers.Base
public class ServiceConnector : IServiceConnector
{
public virtual string ConfigURL
{
get;
protected set;
}
public virtual string ConfigName
{
get;
protected set;
}
public virtual string ConfigFile
{
get;
protected set;
}
public virtual IConfigSource Config
{
get;
protected set;
}
public ServiceConnector(IConfigSource config, IHttpServer server, string configName)
{
}
// We call this from our plugin module to get our configuration
public IConfig GetConfig()
{
IConfig config = null;
config = ServerUtils.GetConfig(ConfigFile, ConfigName);
// Our file is not here? We can get one to bootstrap our plugin module
if ( config == null )
{
IConfigSource remotesource = GetConfigSource();
if (remotesource != null)
{
IniConfigSource initialconfig = new IniConfigSource();
initialconfig.Merge (remotesource);
initialconfig.Save(ConfigFile);
}
config = remotesource.Configs[ConfigName];
}
return config;
}
// We get our remote initial configuration for bootstrapping
private IConfigSource GetConfigSource()
{
IConfigSource source = null;
source = ServerUtils.LoadInitialConfig(ConfigURL);
if (source == null)
System.Console.WriteLine(String.Format ("Config Url: {0} Not found!", ConfigURL));
return source;
}
}
}

View File

@ -23,6 +23,10 @@
[Startup]
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8002/OpenSim.Server.Handlers.dll:GatekeeperServiceInConnector,8002/OpenSim.Server.Handlers.dll:UserAgentServerConnector,HGInventoryService@8002/OpenSim.Server.Handlers.dll:XInventoryInConnector,HGAssetService@8002/OpenSim.Server.Handlers.dll:AssetServiceConnector,8002/OpenSim.Server.Handlers.dll:HeloServiceInConnector,8002/OpenSim.Server.Handlers.dll:HGFriendsServerConnector,8002/OpenSim.Server.Handlers.dll:InstantMessageServerConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector"
; Modular configurations
; Set path to directory for modular ini files...
ConfigDirectory = "/home/opensim/etc/Configs"
; * This is common for all services, it's the network setup for the entire
; * server instance, if none is specified above
; *

View File

@ -15,6 +15,11 @@
[Startup]
ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8003/OpenSim.Server.Handlers.dll:MapAddServiceConnector,8002/OpenSim.Server.Handlers.dll:MapGetServiceConnector"
; Modular configurations
; Set path to directory for modular ini files...
ConfigDirectory = "/home/opensim/etc/Configs"
; * This is common for all services, it's the network setup for the entire
; * server instance, if none is specified above
; *