From 34d21ac94b227e0ab7c089000751e746ccf004a8 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 2 Feb 2008 00:09:55 +0000 Subject: [PATCH] Added some error checking to MaintenanceThread, no-crash (just log) loading of script engines, and support to load multiple script engines --- OpenSim/Region/Application/OpenSimMain.cs | 14 +++- .../ScriptEngineBase/MaintenanceThread.cs | 64 ++++++++++--------- bin/OpenSim.ini.example | 27 ++++++-- 3 files changed, 69 insertions(+), 36 deletions(-) diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index ad5a960442..7d3f7b816c 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -455,7 +455,19 @@ namespace OpenSim //m_moduleLoader.PickupModules(scene, "ScriptEngines"); //m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene); MainLog.Instance.Verbose("MODULES", "Loading scripting engine modules"); - m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene); + foreach (string module in m_scriptEngine.Split(';')) + { + string mod = module.Trim(" \t\r\n".ToCharArray()); // Clean up name + MainLog.Instance.Verbose("MODULES", "Loading scripting engine: " + mod); + try + { + m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene); + } + catch (Exception ex) + { + MainLog.Instance.Error("MODULES", "Failed to load script engine: " + ex.ToString()); + } + } m_moduleLoader.InitialiseSharedModules(scene); scene.SetModuleInterfaces(); diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs index 105d47f75d..842bac9468 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/MaintenanceThread.cs @@ -95,40 +95,44 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase System.Threading.Thread.Sleep(MaintenanceLoopms); // Sleep before next pass if (PleaseShutdown) return; - // - // Re-reading config every x seconds - // - if (m_ScriptEngine.RefreshConfigFileSeconds > 0) - { - // Check if its time to re-read config - if (DateTime.Now.Ticks - Last_ReReadConfigFilens > m_ScriptEngine.RefreshConfigFilens) - { - // Its time to re-read config file - m_ScriptEngine.ConfigSource.Reload(); // Refresh config - m_ScriptEngine.ReadConfig(); - Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time - } - } - // - // Adjust number of running script threads if not correct - // - m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); - - // - // Check if any script has exceeded its max execution time - // - if (m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime) + if (m_ScriptEngine != null) { - // We are enforcing execution time - if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > - m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens) + // + // Re-reading config every x seconds + // + if (m_ScriptEngine.RefreshConfigFileSeconds > 0) { - // Its time to check again - m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check - Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time + // Check if its time to re-read config + if (DateTime.Now.Ticks - Last_ReReadConfigFilens > m_ScriptEngine.RefreshConfigFilens) + { + // Its time to re-read config file + m_ScriptEngine.ReadConfig(); + Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time + } } - } + + // + // Adjust number of running script threads if not correct + // + if (m_ScriptEngine.m_EventQueueManager != null) + m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); + + // + // Check if any script has exceeded its max execution time + // + if (m_ScriptEngine.m_EventQueueManager != null && m_ScriptEngine.m_EventQueueManager.EnforceMaxExecutionTime) + { + // We are enforcing execution time + if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > + m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens) + { + // Its time to check again + m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check + Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time + } + } + } // m_ScriptEngine != null } } catch (Exception ex) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 94bacd1adf..a403855288 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -51,11 +51,6 @@ asset_database = "sqlite" verbose = true -; ScriptEngine -script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll -;Experimental remote ScriptServer plugin: -;script_engine = OpenSim.Region.ScriptEngine.RemoteServer.dll - ; if you would like to allow prim to be physical and move by physics with the physical checkbox in the client set this to true. physical_prim = true @@ -115,7 +110,29 @@ shout_distance = 100 ; make for smoother sun transition at the cost of network ;frame_rate = 100 + +; ## +; ## ScriptEngine +; ## +; These are region modules loaded into each region to provide script support +; Scripts may be everything from LSL or C# scripts put in prims to whole game systems that controls the whole grid. +; You can load multiple modules by separating them with ;. +; +; Example: +;script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll;OpenSim.Region.ScriptEngine.RemoteServer.dll +; +; This is the current and most stable ScriptEngine: +script_engine = OpenSim.Region.ScriptEngine.DotNetEngine.dll + +;Experimental remote ScriptServer plugin (does not currently work): +;script_engine = OpenSim.Region.ScriptEngine.RemoteServer.dll + + [ScriptEngine.DotNetEngine] +; +; These settings are specific to DotNetEngine script engine +; Other script engines based on OpenSim.Region.ScriptEngine.Common.dll will have almost identical settings, but in another section of this config file. +; ; When a script receives an event the event is queued. ; Any free thread will start executing this event. One script can only have one event executed simultaneously.