diff options
author | Melanie Thielker | 2009-04-01 12:13:42 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-04-01 12:13:42 +0000 |
commit | 76ca0963847d75d2d7233ad965c74e50a09d6dce (patch) | |
tree | 12412cb66c3974abb79096901825c7a2065c24e7 /OpenSim/Framework/Servers/BaseOpenSimServer.cs | |
parent | * MRM Adjustments (diff) | |
download | opensim-SC-76ca0963847d75d2d7233ad965c74e50a09d6dce.zip opensim-SC-76ca0963847d75d2d7233ad965c74e50a09d6dce.tar.gz opensim-SC-76ca0963847d75d2d7233ad965c74e50a09d6dce.tar.bz2 opensim-SC-76ca0963847d75d2d7233ad965c74e50a09d6dce.tar.xz |
Add a PIDFile in [Startup], which the PID will be written to
Diffstat (limited to 'OpenSim/Framework/Servers/BaseOpenSimServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 8ede8f5..9794a10 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -73,6 +73,8 @@ namespace OpenSim.Framework.Servers | |||
73 | /// </summary> | 73 | /// </summary> |
74 | protected string m_version; | 74 | protected string m_version; |
75 | 75 | ||
76 | protected string m_pidFile = String.Empty; | ||
77 | |||
76 | protected BaseHttpServer m_httpServer; | 78 | protected BaseHttpServer m_httpServer; |
77 | public BaseHttpServer HttpServer | 79 | public BaseHttpServer HttpServer |
78 | { | 80 | { |
@@ -278,6 +280,7 @@ namespace OpenSim.Framework.Servers | |||
278 | ShutdownSpecific(); | 280 | ShutdownSpecific(); |
279 | 281 | ||
280 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); | 282 | m_log.Info("[SHUTDOWN]: Shutdown processing on main thread complete. Exiting..."); |
283 | RemovePIDFile(); | ||
281 | 284 | ||
282 | Environment.Exit(0); | 285 | Environment.Exit(0); |
283 | } | 286 | } |
@@ -433,5 +436,38 @@ namespace OpenSim.Framework.Servers | |||
433 | 436 | ||
434 | m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); | 437 | m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); |
435 | } | 438 | } |
439 | |||
440 | protected void CreatePIDFile(string path) | ||
441 | { | ||
442 | try | ||
443 | { | ||
444 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
445 | FileStream fs = File.Create(path); | ||
446 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
447 | Byte[] buf = enc.GetBytes(pidstring); | ||
448 | fs.Write(buf, 0, buf.Length); | ||
449 | fs.Close(); | ||
450 | m_pidFile = path; | ||
451 | } | ||
452 | catch (Exception) | ||
453 | { | ||
454 | } | ||
455 | } | ||
456 | |||
457 | |||
458 | protected void RemovePIDFile() | ||
459 | { | ||
460 | if (m_pidFile != String.Empty) | ||
461 | { | ||
462 | try | ||
463 | { | ||
464 | File.Delete(m_pidFile); | ||
465 | m_pidFile = String.Empty; | ||
466 | } | ||
467 | catch (Exception) | ||
468 | { | ||
469 | } | ||
470 | } | ||
471 | } | ||
436 | } | 472 | } |
437 | } | 473 | } |