* Tidy up configuration stuff, eliminated default setting duplication along the way

* This revision also makes the exception catcher of last resort print to the log instead of just the console
* This means logs should now capture sim crashing exceptions, though not those which are caused by a crash of the virtual machine itself
0.6.0-stable
Justin Clarke Casey 2008-10-04 20:27:55 +00:00
parent 344e33b8fc
commit 31362a67df
2 changed files with 45 additions and 58 deletions

View File

@ -27,6 +27,8 @@
using System;
using System.Net;
using System.Reflection;
using log4net;
using log4net.Config;
using Nini.Config;
using OpenSim.Framework;
@ -36,6 +38,8 @@ namespace OpenSim
{
public class Application
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string iniFilePath = "";
//could move our main function into OpenSimMain and kill this class
@ -124,9 +128,7 @@ namespace OpenSim
msg += "\r\n";
msg += "Application is terminating: " + e.IsTerminating.ToString() + "\r\n";
// Do we not always want to see exception messages?
// if (e.IsTerminating)
MainConsole.Instance.Error("[APPLICATION]: " + msg);
m_log.ErrorFormat("[APPLICATION]: {0}", msg);
// Try to post errormessage to an URL
try

View File

@ -150,48 +150,39 @@ namespace OpenSim
set { m_moduleLoader = value; }
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="configSource"></param>
public OpenSimBase(IConfigSource configSource) : base()
{
IConfig startupConfig = configSource.Configs["Startup"];
Application.iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini");
string iniFileName = startupConfig.GetString("inifile", "OpenSim.ini");
Application.iniFilePath = Path.Combine(Util.configDir(), iniFileName);
m_config = new OpenSimConfigSource();
m_config.Source = new IniConfigSource();
// IConfigSource icong;
m_config.Source.Merge(DefaultConfig());
//check for .INI file (either default or name passed in command line)
if (File.Exists(Application.iniFilePath))
{
// From reading Nini's code, it seems that later merged keys replace earlier ones.
m_config.Source.Merge(new IniConfigSource(Application.iniFilePath));
m_config.Source.Merge(configSource);
}
else
{
Application.iniFilePath = Path.Combine(Util.configDir(), Application.iniFilePath);
// check for a xml config file
Application.iniFilePath = Path.Combine(Util.configDir(), "OpenSim.xml");
if (File.Exists(Application.iniFilePath))
{
m_config.Source.Merge(new IniConfigSource(Application.iniFilePath));
m_config.Source = new XmlConfigSource();
m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
m_config.Source.Merge(configSource);
}
else
{
if (File.Exists("OpenSim.xml"))
{
// check for a xml config file
Application.iniFilePath = "OpenSim.xml";
m_config.Source = new XmlConfigSource();
m_config.Source.Merge(new XmlConfigSource(Application.iniFilePath));
m_config.Source.Merge(configSource);
}
else
{
// using OpenSim.ini instead
m_config.Source.Merge(DefaultConfig());
m_config.Source.Merge(configSource);
m_config.Save(Application.iniFilePath);
}
}
}
ReadConfigSettings();
@ -213,6 +204,7 @@ namespace OpenSim
config.Set("gridmode", false);
config.Set("physics", "basicphysics");
config.Set("meshing", "ZeroMesher");
config.Set("physical_prim", true);
config.Set("see_into_this_sim_from_neighbor", true);
config.Set("serverside_object_permissions", false);
@ -223,7 +215,6 @@ namespace OpenSim
config.Set("shutdown_console_commands_file", String.Empty);
config.Set("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
config.Set("DefaultScriptEngine", "DotNetEngine");
config.Set("asset_database", "sqlite");
config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
}
@ -277,48 +268,42 @@ namespace OpenSim
if (startupConfig != null)
{
m_sandbox = !startupConfig.GetBoolean("gridmode", false);
m_physicsEngine = startupConfig.GetString("physics", "basicphysics");
m_meshEngineName = startupConfig.GetString("meshing", "ZeroMesher");
m_sandbox = !startupConfig.GetBoolean("gridmode");
m_physicsEngine = startupConfig.GetString("physics");
m_meshEngineName = startupConfig.GetString("meshing");
m_physicalPrim = startupConfig.GetBoolean("physical_prim", true);
m_physicalPrim = startupConfig.GetBoolean("physical_prim");
m_see_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor", true);
m_see_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor");
m_storageDll = startupConfig.GetString("storage_plugin", "OpenSim.Data.SQLite.dll");
m_storageDll = startupConfig.GetString("storage_plugin");
if (m_storageDll == "OpenSim.DataStore.MonoSqlite.dll")
{
m_storageDll = "OpenSim.Data.SQLite.dll";
Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Data.SQLite.dll.");
Thread.Sleep(3000);
}
m_storageConnectionString
= startupConfig.GetString("storage_connection_string", "URI=file:OpenSim.db,version=3");
m_estateConnectionString
= startupConfig.GetString("estate_connection_string", m_storageConnectionString);
m_assetStorage = startupConfig.GetString("asset_database", "local");
m_clientstackDll = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
m_storageConnectionString = startupConfig.GetString("storage_connection_string");
m_estateConnectionString = startupConfig.GetString("estate_connection_string", m_storageConnectionString);
m_assetStorage = startupConfig.GetString("asset_database");
m_clientstackDll = startupConfig.GetString("clientstack_plugin");
}
IConfig standaloneConfig = m_config.Source.Configs["StandAlone"];
if (standaloneConfig != null)
{
m_standaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate", false);
m_standaloneWelcomeMessage = standaloneConfig.GetString("welcome_message", "Welcome to OpenSim");
m_standaloneInventoryPlugin =
standaloneConfig.GetString("inventory_plugin", "OpenSim.Data.SQLite.dll");
m_standaloneInventorySource =
standaloneConfig.GetString("inventory_source","");
m_standaloneUserPlugin =
standaloneConfig.GetString("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
m_standaloneUserSource =
standaloneConfig.GetString("user_source","");
m_standaloneAssetPlugin =
standaloneConfig.GetString("asset_plugin", "OpenSim.Data.SQLite.dll");
m_standaloneAssetSource =
standaloneConfig.GetString("asset_source","");
m_standaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate");
m_standaloneWelcomeMessage = standaloneConfig.GetString("welcome_message");
m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false);
m_standaloneInventoryPlugin = standaloneConfig.GetString("inventory_plugin");
m_standaloneInventorySource = standaloneConfig.GetString("inventory_source");
m_standaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin");
m_standaloneUserSource = standaloneConfig.GetString("user_source");
m_standaloneAssetPlugin = standaloneConfig.GetString("asset_plugin");
m_standaloneAssetSource = standaloneConfig.GetString("asset_source");
m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file");
}
m_networkServersInfo.loadFromConfiguration(m_config.Source);