Added some error checking to MaintenanceThread, no-crash (just log) loading of script engines, and support to load multiple script engines

ThreadPoolClientBranch
Tedd Hansen 2008-02-02 00:09:55 +00:00
parent 694642a482
commit 34d21ac94b
3 changed files with 69 additions and 36 deletions

View File

@ -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();

View File

@ -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)

View File

@ -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.