aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/ServerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/ServerBase.cs')
-rw-r--r--OpenSim/Framework/Servers/ServerBase.cs51
1 files changed, 46 insertions, 5 deletions
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
index 9973a2d..645b43a 100644
--- a/OpenSim/Framework/Servers/ServerBase.cs
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -55,6 +55,8 @@ namespace OpenSim.Framework.Servers
55 protected DateTime m_startuptime; 55 protected DateTime m_startuptime;
56 protected string m_startupDirectory = Environment.CurrentDirectory; 56 protected string m_startupDirectory = Environment.CurrentDirectory;
57 57
58 protected string m_pidFile = String.Empty;
59
58 /// <summary> 60 /// <summary>
59 /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. 61 /// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
60 /// </summary> 62 /// </summary>
@@ -67,6 +69,45 @@ namespace OpenSim.Framework.Servers
67 EnhanceVersionInformation(); 69 EnhanceVersionInformation();
68 } 70 }
69 71
72 protected void CreatePIDFile(string path)
73 {
74 try
75 {
76 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
77
78 using (FileStream fs = File.Create(path))
79 {
80 Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
81 fs.Write(buf, 0, buf.Length);
82 }
83
84 m_pidFile = path;
85
86 m_log.InfoFormat("[SERVER BASE]: Created pid file {0}", m_pidFile);
87 }
88 catch (Exception e)
89 {
90 m_log.Warn(string.Format("[SERVER BASE]: Could not create PID file at {0} ", path), e);
91 }
92 }
93
94 protected void RemovePIDFile()
95 {
96 if (m_pidFile != String.Empty)
97 {
98 try
99 {
100 File.Delete(m_pidFile);
101 }
102 catch (Exception e)
103 {
104 m_log.Error(string.Format("[SERVER BASE]: Error whilst removing {0} ", m_pidFile), e);
105 }
106
107 m_pidFile = String.Empty;
108 }
109 }
110
70 public void RegisterCommonAppenders(IConfig startupConfig) 111 public void RegisterCommonAppenders(IConfig startupConfig)
71 { 112 {
72 ILoggerRepository repository = LogManager.GetRepository(); 113 ILoggerRepository repository = LogManager.GetRepository();
@@ -109,7 +150,7 @@ namespace OpenSim.Framework.Servers
109 m_logFileAppender.ActivateOptions(); 150 m_logFileAppender.ActivateOptions();
110 } 151 }
111 152
112 m_log.InfoFormat("[LOGGING]: Logging started to file {0}", m_logFileAppender.File); 153 m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File);
113 } 154 }
114 } 155 }
115 156
@@ -243,26 +284,26 @@ namespace OpenSim.Framework.Servers
243 } 284 }
244 else if (File.Exists(gitRefPointerPath)) 285 else if (File.Exists(gitRefPointerPath))
245 { 286 {
246// m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath); 287// m_log.DebugFormat("[SERVER BASE]: Found {0}", gitRefPointerPath);
247 288
248 string rawPointer = ""; 289 string rawPointer = "";
249 290
250 using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) 291 using (StreamReader pointerFile = File.OpenText(gitRefPointerPath))
251 rawPointer = pointerFile.ReadLine(); 292 rawPointer = pointerFile.ReadLine();
252 293
253// m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer); 294// m_log.DebugFormat("[SERVER BASE]: rawPointer [{0}]", rawPointer);
254 295
255 Match m = Regex.Match(rawPointer, "^ref: (.+)$"); 296 Match m = Regex.Match(rawPointer, "^ref: (.+)$");
256 297
257 if (m.Success) 298 if (m.Success)
258 { 299 {
259// m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value); 300// m_log.DebugFormat("[SERVER BASE]: Matched [{0}]", m.Groups[1].Value);
260 301
261 string gitRef = m.Groups[1].Value; 302 string gitRef = m.Groups[1].Value;
262 string gitRefPath = gitDir + gitRef; 303 string gitRefPath = gitDir + gitRef;
263 if (File.Exists(gitRefPath)) 304 if (File.Exists(gitRefPath))
264 { 305 {
265// m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath); 306// m_log.DebugFormat("[SERVER BASE]: Found gitRefPath [{0}]", gitRefPath);
266 307
267 using (StreamReader refFile = File.OpenText(gitRefPath)) 308 using (StreamReader refFile = File.OpenText(gitRefPath))
268 { 309 {