From f836710af510e25d9861997ad0dcea3ee3001934 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 19 Oct 2011 21:34:55 +0100
Subject: minor: improve command help on scripts suspend/resume
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 5ee8dbf..acbf7df 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -278,12 +278,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
MainConsole.Instance.Commands.AddCommand(
"scripts", false, "scripts suspend", "scripts suspend", "Suspend all scripts",
"Suspends all currently running scripts. This only suspends event delivery, it will not suspend a"
- + " script that is currently processing an event.",
+ + " script that is currently processing an event.\n"
+ + "Suspended scripts will continue to accumulate events but won't process them.",
HandleSuspendScripts);
MainConsole.Instance.Commands.AddCommand(
"scripts", false, "scripts resume", "scripts resume", "Resume all scripts",
- "Resumes all currently suspended scripts", HandleResumeScripts);
+ "Resumes all currently suspended scripts.\n"
+ + "Resumed scripts will process all events accumulated whilst suspended.",
+ HandleResumeScripts);
}
public void HandleShowScripts(string module, string[] cmdparams)
--
cgit v1.1
From 32c3faedd609cbaf5f17a866c41925105b690766 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 19 Oct 2011 21:40:28 +0100
Subject: Add "scripts stop" and "scripts start" console commands.
These will stop all running scripts and start all stopped scripts respectively.
A stopped script does not save any events for later processing.
---
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 50 ++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index acbf7df..003e735 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -276,17 +276,25 @@ namespace OpenSim.Region.ScriptEngine.XEngine
"Synonym for scripts show command", HandleShowScripts);
MainConsole.Instance.Commands.AddCommand(
- "scripts", false, "scripts suspend", "scripts suspend", "Suspend all scripts",
+ "scripts", false, "scripts suspend", "scripts suspend", "Suspends all running scripts",
"Suspends all currently running scripts. This only suspends event delivery, it will not suspend a"
+ " script that is currently processing an event.\n"
+ "Suspended scripts will continue to accumulate events but won't process them.",
HandleSuspendScripts);
MainConsole.Instance.Commands.AddCommand(
- "scripts", false, "scripts resume", "scripts resume", "Resume all scripts",
+ "scripts", false, "scripts resume", "scripts resume", "Resumes all suspended scripts",
"Resumes all currently suspended scripts.\n"
+ "Resumed scripts will process all events accumulated whilst suspended.",
HandleResumeScripts);
+
+ MainConsole.Instance.Commands.AddCommand(
+ "scripts", false, "scripts stop", "scripts stop", "Stops all running scripts",
+ HandleStopScripts);
+
+ MainConsole.Instance.Commands.AddCommand(
+ "scripts", false, "scripts start", "scripts start", "Starts all stopped scripts",
+ HandleStartScripts);
}
public void HandleShowScripts(string module, string[] cmdparams)
@@ -364,6 +372,44 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
+ public void HandleStartScripts(string module, string[] cmdparams)
+ {
+ lock (m_Scripts)
+ {
+ foreach (IScriptInstance instance in m_Scripts.Values)
+ {
+ if (!instance.Running)
+ {
+ instance.Start();
+
+ SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
+ MainConsole.Instance.OutputFormat(
+ "Started {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
+ instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
+ }
+ }
+ }
+ }
+
+ public void HandleStopScripts(string module, string[] cmdparams)
+ {
+ lock (m_Scripts)
+ {
+ foreach (IScriptInstance instance in m_Scripts.Values)
+ {
+ if (instance.Running)
+ {
+ instance.Stop(0);
+
+ SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
+ MainConsole.Instance.OutputFormat(
+ "Stopped {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
+ instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
+ }
+ }
+ }
+ }
+
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
--
cgit v1.1
From 601dabb1b73a894e4f2f61abe6e9053d380008cd Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 19 Oct 2011 22:30:31 +0100
Subject: Extend scripts stop/start/suspend/resume console commands to allow
action on a single script by giving the script item id (which can be found
via scripts show).
Not an ideal way to do this on a region with many scripts. Needs refinement later.
---
.../Region/Framework/Interfaces/IScriptModule.cs | 14 +-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 158 ++++++++++++---------
2 files changed, 100 insertions(+), 72 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index b27b7da..950e4b0 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -41,12 +41,16 @@ namespace OpenSim.Region.Framework.Interfaces
bool PostScriptEvent(UUID itemID, string name, Object[] args);
bool PostObjectEvent(UUID itemID, string name, Object[] args);
- // Suspend ALL scripts in a given scene object. The item ID
- // is the UUID of a SOG, and the method acts on all contained
- // scripts. This is different from the suspend/resume that
- // can be issued by a client.
- //
+ ///
+ /// Suspends a script.
+ ///
+ /// The item ID of the script.
void SuspendScript(UUID itemID);
+
+ ///
+ /// Resumes a script.
+ ///
+ /// The item ID of the script.
void ResumeScript(UUID itemID);
ArrayList GetScriptErrors(UUID itemID);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 003e735..240e36f 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -276,25 +276,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine
"Synonym for scripts show command", HandleShowScripts);
MainConsole.Instance.Commands.AddCommand(
- "scripts", false, "scripts suspend", "scripts suspend", "Suspends all running scripts",
+ "scripts", false, "scripts suspend", "scripts suspend []", "Suspends all running scripts",
"Suspends all currently running scripts. This only suspends event delivery, it will not suspend a"
+ " script that is currently processing an event.\n"
- + "Suspended scripts will continue to accumulate events but won't process them.",
- HandleSuspendScripts);
+ + "Suspended scripts will continue to accumulate events but won't process them.\n"
+ + "If a is given then only that script will be suspended. Otherwise, all suitable scripts are suspended.",
+ (module, cmdparams) => HandleScriptsAction(cmdparams, HandleSuspendScript));
MainConsole.Instance.Commands.AddCommand(
- "scripts", false, "scripts resume", "scripts resume", "Resumes all suspended scripts",
+ "scripts", false, "scripts resume", "scripts resume []", "Resumes all suspended scripts",
"Resumes all currently suspended scripts.\n"
- + "Resumed scripts will process all events accumulated whilst suspended.",
- HandleResumeScripts);
+ + "Resumed scripts will process all events accumulated whilst suspended."
+ + "If a is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.",
+ (module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript));
MainConsole.Instance.Commands.AddCommand(
- "scripts", false, "scripts stop", "scripts stop", "Stops all running scripts",
- HandleStopScripts);
+ "scripts", false, "scripts stop", "scripts stop []", "Stops all running scripts",
+ "Stops all running scripts."
+ + "If a is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.",
+ (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript));
MainConsole.Instance.Commands.AddCommand(
- "scripts", false, "scripts start", "scripts start", "Starts all stopped scripts",
- HandleStartScripts);
+ "scripts", false, "scripts start", "scripts start []", "Starts all stopped scripts",
+ "Starts all stopped scripts."
+ + "If a is given then only that script will be started. Otherwise, all suitable scripts are started.",
+ (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript));
}
public void HandleShowScripts(string module, string[] cmdparams)
@@ -334,79 +340,101 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
- public void HandleSuspendScripts(string module, string[] cmdparams)
+ ///
+ /// Parse the raw item id into a script instance from the command params if it's present.
+ ///
+ ///
+ ///
+ /// true if we're okay to proceed, false if not.
+ private void HandleScriptsAction(string[] cmdparams, Action action)
{
lock (m_Scripts)
{
- foreach (IScriptInstance instance in m_Scripts.Values)
+ string rawItemId;
+ UUID itemId = UUID.Zero;
+
+ if (cmdparams.Length == 2)
{
- if (!instance.Suspended)
- {
- instance.Suspend();
+ foreach (IScriptInstance instance in m_Scripts.Values)
+ action(instance);
- SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
- MainConsole.Instance.OutputFormat(
- "Suspended {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
- instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
+ return;
+ }
+
+ rawItemId = cmdparams[2];
+
+ if (!UUID.TryParse(rawItemId, out itemId))
+ {
+ MainConsole.Instance.OutputFormat("Error - {0} is not a valid UUID", rawItemId);
+ return;
+ }
+
+ if (itemId != UUID.Zero)
+ {
+ IScriptInstance instance = GetInstance(itemId);
+ if (instance == null)
+ {
+ MainConsole.Instance.OutputFormat("Error - No item found with id {0}", itemId);
+ return;
+ }
+ else
+ {
+ action(instance);
+ return;
}
}
}
}
- public void HandleResumeScripts(string module, string[] cmdparams)
+ private void HandleSuspendScript(IScriptInstance instance)
{
- lock (m_Scripts)
+ if (!instance.Suspended)
{
- foreach (IScriptInstance instance in m_Scripts.Values)
- {
- if (instance.Suspended)
- {
- instance.Resume();
+ instance.Suspend();
- SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
- MainConsole.Instance.OutputFormat(
- "Resumed {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
- instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
- }
- }
+ SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
+ MainConsole.Instance.OutputFormat(
+ "Suspended {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
+ instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
}
}
- public void HandleStartScripts(string module, string[] cmdparams)
+ private void HandleResumeScript(IScriptInstance instance)
{
- lock (m_Scripts)
+ if (instance.Suspended)
{
- foreach (IScriptInstance instance in m_Scripts.Values)
- {
- if (!instance.Running)
- {
- instance.Start();
+ instance.Resume();
- SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
- MainConsole.Instance.OutputFormat(
- "Started {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
- instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
- }
- }
+ SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
+ MainConsole.Instance.OutputFormat(
+ "Resumed {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
+ instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
}
}
- public void HandleStopScripts(string module, string[] cmdparams)
+ private void HandleStartScript(IScriptInstance instance)
{
- lock (m_Scripts)
+ if (!instance.Running)
{
- foreach (IScriptInstance instance in m_Scripts.Values)
- {
- if (instance.Running)
- {
- instance.Stop(0);
+ instance.Start();
- SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
- MainConsole.Instance.OutputFormat(
- "Stopped {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
- instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
- }
- }
+ SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
+ MainConsole.Instance.OutputFormat(
+ "Started {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
+ instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
+ }
+ }
+
+ private void HandleStopScript(IScriptInstance instance)
+ {
+ if (instance.Running)
+ {
+ instance.Stop(0);
+
+ SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
+ MainConsole.Instance.OutputFormat(
+ "Stopped {0}.{1}, item UUID {2}, prim UUID {3} @ {4}",
+ instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, sop.AbsolutePosition);
}
}
@@ -1770,19 +1798,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void SuspendScript(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
- if (instance == null)
- return;
-
- instance.Suspend();
+ if (instance != null)
+ instance.Suspend();
}
public void ResumeScript(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
- if (instance == null)
- return;
-
- instance.Resume();
+ if (instance != null)
+ instance.Resume();
}
}
-}
+}
\ No newline at end of file
--
cgit v1.1