mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 14:16:07 +08:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user