From 2db5de3e7217ca4bd9fcaf5345ea5672b5d6663f Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 2 Feb 2008 07:35:51 +0000 Subject: Added commands to change config file from console: CONFIG SET section key value value value CONFIG GET section key CONFIG SAVE (it saves, but does it save correctly?:) ScriptEngine will react correctly to any config change made while it is running. --- OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | 16 ++++-- OpenSim/Framework/RegionInfo.cs | 2 +- OpenSim/Region/Application/OpenSimMain.cs | 63 +++++++++++++++++++++- OpenSim/Region/ClientStack/UDPServer.cs | 2 +- .../Common/ScriptEngineBase/ScriptEngine.cs | 12 ++--- 5 files changed, 83 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs index 45d0720..b25924c 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs @@ -415,11 +415,12 @@ namespace OpenSim.Framework.Data.MySQL } } + static Random rnd = new Random(); public void StoreLandObject(Land parcel, LLUUID regionUUID) { // Does the new locking fix it? - //MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))"); - //System.Threading.Thread.Sleep(3000); + MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))"); + System.Threading.Thread.Sleep(2500 + rnd.Next(300, 900)); lock (DBAccessLock) { @@ -1469,7 +1470,16 @@ namespace OpenSim.Framework.Data.MySQL if (conn.State != ConnectionState.Open) { - conn.Open(); + try + { + conn.Open(); + } + catch (Exception ex) + { + MainLog.Instance.Error("MySql", "Error connecting to MySQL server: " + ex.Message); + MainLog.Instance.Error("MySql", "Application is terminating!"); + System.Threading.Thread.CurrentThread.Abort(); + } } try diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index b843774..be0b3e0 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -310,7 +310,7 @@ namespace OpenSim.Framework NetworkServersInfo.DefaultHttpListenerPort.ToString(), false); configMember.addConfigurationOption("allow_alternate_ports", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, "Allow sim to find alternate UDP ports when ports are in use?", - "false", false); + "false", true); configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "External Host Name", "127.0.0.1", false); diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 8934be2..223b4a5 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -720,6 +720,9 @@ namespace OpenSim m_log.Error("show modules - shows info aboutloaded modules."); m_log.Error("stats - statistical information for this server not displayed in the client"); m_log.Error("shutdown - disconnect all clients and shutdown."); + m_log.Error("config set category field value - set a config value"); + m_log.Error("config get category field - get a config value"); + m_log.Error("config save - save OpenSim.ini"); m_log.Error("terrain help - show help for terrain commands."); break; @@ -911,8 +914,66 @@ namespace OpenSim MainLog.Instance.Notice("STATS", "Extra statistics collection has not been enabled"); } break; - + case "config": + string n = command.ToUpper(); + if (cmdparams.Length > 0) + { + switch (cmdparams[0].ToLower()) + { + case "set": + if (cmdparams.Length < 4) + { + MainLog.Instance.Notice(n, "SYNTAX: " + n + " SET SECTION KEY VALUE"); + MainLog.Instance.Notice(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); + } + else + { + IConfig c = DefaultConfig().Configs[cmdparams[1]]; + if (c == null) + c = DefaultConfig().AddConfig(cmdparams[1]); + string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); + c.Set(cmdparams[2], _value); + m_config.Merge(c.ConfigSource); + + MainLog.Instance.Notice(n, + n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " + + _value); + } + break; + case "get": + if (cmdparams.Length < 3) + { + MainLog.Instance.Notice(n, "SYNTAX: " + n + " GET SECTION KEY"); + MainLog.Instance.Notice(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads"); + } + else + { + IConfig c = DefaultConfig().Configs[cmdparams[1]]; + if (c == null) + { + MainLog.Instance.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist."); + break; + } + else + { + MainLog.Instance.Notice(n, + n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " + + c.GetString(cmdparams[2])); + } + } + + break; + case "save": + MainLog.Instance.Notice(n, "Saving configuration file: " + Application.iniFilePath); + m_config.Save(Application.iniFilePath); + break; + } + } + else + { + } + break; default: m_log.Error("Unknown command"); break; diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index e292c2c..0fd3486 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -257,7 +257,7 @@ namespace OpenSim.Region.ClientStack { uint newPort = listenPort; - for (uint i = 0; i < 10; i++) + for (uint i = 0; i < 20; i++) { newPort = listenPort + i; m_log.Verbose("SERVER", "Opening UDP socket on " + listenIP.ToString() + " " + newPort + ". Allow alternate ports: " + Allow_Alternate_Port.ToString()); diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs index 0b58da0..4cf39b4 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs @@ -134,14 +134,14 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase #if DEBUG Log.Debug(ScriptEngineName, "Refreshing configuration for all modules"); #endif - RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 0); + RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 30); - // Reload from disk + // Reload from disk? No! //ConfigSource.Reload(); - if (File.Exists(OpenSim.Application.iniFilePath)) - { - //ConfigSource.Merge(new IniConfigSource(OpenSim.Application.iniFilePath)); - } + //if (File.Exists(OpenSim.Application.iniFilePath)) + //{ + // //ConfigSource.Merge(new IniConfigSource(OpenSim.Application.iniFilePath)); + //} // Create a new object (probably not necessary?) -- cgit v1.1