aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2010-11-26 03:21:51 +0100
committerMelanie2010-11-26 03:21:51 +0100
commitcccfd1db3478d20ea63c009b01bdc3479c046cbf (patch)
tree602d4b36c194441d82022f71a65d9295e1587a50
parentAllow group lookup during tp / login to make restricting parcels to group (diff)
downloadopensim-SC_OLD-cccfd1db3478d20ea63c009b01bdc3479c046cbf.zip
opensim-SC_OLD-cccfd1db3478d20ea63c009b01bdc3479c046cbf.tar.gz
opensim-SC_OLD-cccfd1db3478d20ea63c009b01bdc3479c046cbf.tar.bz2
opensim-SC_OLD-cccfd1db3478d20ea63c009b01bdc3479c046cbf.tar.xz
Add marker files to the restart module so external scripts can be used to
kill a process that hasn't restarted properly
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
index c65aa6a..6e1ee10 100644
--- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Timers; 30using System.Timers;
31using System.IO;
32using System.Diagnostics;
31using System.Threading; 33using System.Threading;
32using System.Collections.Generic; 34using System.Collections.Generic;
33using log4net; 35using log4net;
@@ -56,13 +58,23 @@ namespace OpenSim.Region.CoreModules.World.Region
56 protected UUID m_Initiator; 58 protected UUID m_Initiator;
57 protected bool m_Notice = false; 59 protected bool m_Notice = false;
58 protected IDialogModule m_DialogModule = null; 60 protected IDialogModule m_DialogModule = null;
61 protected string m_MarkerPath;
59 62
60 public void Initialise(IConfigSource config) 63 public void Initialise(IConfigSource config)
61 { 64 {
65 IConfig restartConfig = config.Configs["RestartModule"];
66 if (restartConfig != null)
67 {
68 m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty);
69 }
62 } 70 }
63 71
64 public void AddRegion(Scene scene) 72 public void AddRegion(Scene scene)
65 { 73 {
74 if (m_MarkerPath != String.Empty)
75 File.Delete(Path.Combine(m_MarkerPath,
76 scene.RegionInfo.RegionID.ToString()));
77
66 m_Scene = scene; 78 m_Scene = scene;
67 scene.RegisterModuleInterface<IRestartModule>(this); 79 scene.RegisterModuleInterface<IRestartModule>(this);
68 MainConsole.Instance.Commands.AddCommand("RestartModule", 80 MainConsole.Instance.Commands.AddCommand("RestartModule",
@@ -114,6 +126,7 @@ namespace OpenSim.Region.CoreModules.World.Region
114 126
115 if (alerts == null) 127 if (alerts == null)
116 { 128 {
129 CreateMarkerFile();
117 m_Scene.RestartNow(); 130 m_Scene.RestartNow();
118 return; 131 return;
119 } 132 }
@@ -127,6 +140,7 @@ namespace OpenSim.Region.CoreModules.World.Region
127 140
128 if (m_Alerts[0] == 0) 141 if (m_Alerts[0] == 0)
129 { 142 {
143 CreateMarkerFile();
130 m_Scene.RestartNow(); 144 m_Scene.RestartNow();
131 return; 145 return;
132 } 146 }
@@ -140,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Region
140 { 154 {
141 if (m_Alerts.Count == 0 || m_Alerts[0] == 0) 155 if (m_Alerts.Count == 0 || m_Alerts[0] == 0)
142 { 156 {
157 CreateMarkerFile();
143 m_Scene.RestartNow(); 158 m_Scene.RestartNow();
144 return 0; 159 return 0;
145 } 160 }
@@ -259,5 +274,25 @@ namespace OpenSim.Region.CoreModules.World.Region
259 274
260 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); 275 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice);
261 } 276 }
277
278 protected void CreateMarkerFile()
279 {
280 if (m_MarkerPath == String.Empty)
281 return;
282
283 string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString());
284 try
285 {
286 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
287 FileStream fs = File.Create(path);
288 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
289 Byte[] buf = enc.GetBytes(pidstring);
290 fs.Write(buf, 0, buf.Length);
291 fs.Close();
292 }
293 catch (Exception)
294 {
295 }
296 }
262 } 297 }
263} 298}