diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 178 |
1 files changed, 1 insertions, 177 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 019b68b..9560171 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -62,19 +62,6 @@ namespace OpenSim.Framework.Servers | |||
62 | /// </summary> | 62 | /// </summary> |
63 | private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); | 63 | private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000); |
64 | 64 | ||
65 | protected OpenSimAppender m_consoleAppender; | ||
66 | protected IAppender m_logFileAppender = null; | ||
67 | |||
68 | /// <summary> | ||
69 | /// Record the initial startup directory for info purposes | ||
70 | /// </summary> | ||
71 | protected string m_startupDirectory = Environment.CurrentDirectory; | ||
72 | |||
73 | /// <summary> | ||
74 | /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. | ||
75 | /// </summary> | ||
76 | protected string m_version; | ||
77 | |||
78 | protected string m_pidFile = String.Empty; | 65 | protected string m_pidFile = String.Empty; |
79 | 66 | ||
80 | /// <summary> | 67 | /// <summary> |
@@ -90,27 +77,11 @@ namespace OpenSim.Framework.Servers | |||
90 | 77 | ||
91 | public BaseOpenSimServer() : base() | 78 | public BaseOpenSimServer() : base() |
92 | { | 79 | { |
93 | m_version = VersionInfo.Version; | ||
94 | |||
95 | // Random uuid for private data | 80 | // Random uuid for private data |
96 | m_osSecret = UUID.Random().ToString(); | 81 | m_osSecret = UUID.Random().ToString(); |
97 | 82 | ||
98 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); | 83 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); |
99 | m_periodicDiagnosticsTimer.Enabled = true; | 84 | m_periodicDiagnosticsTimer.Enabled = true; |
100 | |||
101 | // This thread will go on to become the console listening thread | ||
102 | Thread.CurrentThread.Name = "ConsoleThread"; | ||
103 | |||
104 | ILoggerRepository repository = LogManager.GetRepository(); | ||
105 | IAppender[] appenders = repository.GetAppenders(); | ||
106 | |||
107 | foreach (IAppender appender in appenders) | ||
108 | { | ||
109 | if (appender.Name == "LogFileAppender") | ||
110 | { | ||
111 | m_logFileAppender = appender; | ||
112 | } | ||
113 | } | ||
114 | } | 85 | } |
115 | 86 | ||
116 | /// <summary> | 87 | /// <summary> |
@@ -121,34 +92,6 @@ namespace OpenSim.Framework.Servers | |||
121 | if (m_console == null) | 92 | if (m_console == null) |
122 | return; | 93 | return; |
123 | 94 | ||
124 | ILoggerRepository repository = LogManager.GetRepository(); | ||
125 | IAppender[] appenders = repository.GetAppenders(); | ||
126 | |||
127 | foreach (IAppender appender in appenders) | ||
128 | { | ||
129 | if (appender.Name == "Console") | ||
130 | { | ||
131 | m_consoleAppender = (OpenSimAppender)appender; | ||
132 | break; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | if (null == m_consoleAppender) | ||
137 | { | ||
138 | Notice("No appender named Console found (see the log4net config file for this executable)!"); | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | // FIXME: This should be done through an interface rather than casting. | ||
143 | m_consoleAppender.Console = (ConsoleBase)m_console; | ||
144 | |||
145 | // If there is no threshold set then the threshold is effectively everything. | ||
146 | if (null == m_consoleAppender.Threshold) | ||
147 | m_consoleAppender.Threshold = Level.All; | ||
148 | |||
149 | Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); | ||
150 | } | ||
151 | |||
152 | RegisterCommonCommands(); | 95 | RegisterCommonCommands(); |
153 | 96 | ||
154 | m_console.Commands.AddCommand("General", false, "quit", | 97 | m_console.Commands.AddCommand("General", false, "quit", |
@@ -163,10 +106,6 @@ namespace OpenSim.Framework.Servers | |||
163 | "set log level <level>", | 106 | "set log level <level>", |
164 | "Set the console logging level", HandleLogLevel); | 107 | "Set the console logging level", HandleLogLevel); |
165 | 108 | ||
166 | m_console.Commands.AddCommand("General", false, "show info", | ||
167 | "show info", | ||
168 | "Show general information about the server", HandleShow); | ||
169 | |||
170 | m_console.Commands.AddCommand("General", false, "show threads", | 109 | m_console.Commands.AddCommand("General", false, "show threads", |
171 | "show threads", | 110 | "show threads", |
172 | "Show thread status", HandleShow); | 111 | "Show thread status", HandleShow); |
@@ -279,8 +218,6 @@ namespace OpenSim.Framework.Servers | |||
279 | public virtual void Startup() | 218 | public virtual void Startup() |
280 | { | 219 | { |
281 | m_log.Info("[STARTUP]: Beginning startup processing"); | 220 | m_log.Info("[STARTUP]: Beginning startup processing"); |
282 | |||
283 | EnhanceVersionInformation(); | ||
284 | 221 | ||
285 | m_log.Info("[STARTUP]: OpenSimulator version: " + m_version + Environment.NewLine); | 222 | m_log.Info("[STARTUP]: OpenSimulator version: " + m_version + Environment.NewLine); |
286 | // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and | 223 | // clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and |
@@ -377,10 +314,6 @@ namespace OpenSim.Framework.Servers | |||
377 | 314 | ||
378 | switch (showParams[0]) | 315 | switch (showParams[0]) |
379 | { | 316 | { |
380 | case "info": | ||
381 | ShowInfo(); | ||
382 | break; | ||
383 | |||
384 | case "threads": | 317 | case "threads": |
385 | Notice(GetThreadsReport()); | 318 | Notice(GetThreadsReport()); |
386 | break; | 319 | break; |
@@ -410,116 +343,7 @@ namespace OpenSim.Framework.Servers | |||
410 | MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); | 343 | MainConsole.Instance.OutputFormat("Aborted thread with id {0}", threadId); |
411 | else | 344 | else |
412 | MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); | 345 | MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId); |
413 | } | 346 | } |
414 | |||
415 | protected void ShowInfo() | ||
416 | { | ||
417 | Notice(GetVersionText()); | ||
418 | Notice("Startup directory: " + m_startupDirectory); | ||
419 | if (null != m_consoleAppender) | ||
420 | Notice(String.Format("Console log level: {0}", m_consoleAppender.Threshold)); | ||
421 | } | ||
422 | |||
423 | protected string GetVersionText() | ||
424 | { | ||
425 | return String.Format("Version: {0} (interface version {1})", m_version, VersionInfo.MajorInterfaceVersion); | ||
426 | } | ||
427 | |||
428 | /// <summary> | ||
429 | /// Enhance the version string with extra information if it's available. | ||
430 | /// </summary> | ||
431 | protected void EnhanceVersionInformation() | ||
432 | { | ||
433 | string buildVersion = string.Empty; | ||
434 | |||
435 | // The subversion information is deprecated and will be removed at a later date | ||
436 | // Add subversion revision information if available | ||
437 | // Try file "svn_revision" in the current directory first, then the .svn info. | ||
438 | // This allows to make the revision available in simulators not running from the source tree. | ||
439 | // FIXME: Making an assumption about the directory we're currently in - we do this all over the place | ||
440 | // elsewhere as well | ||
441 | string gitDir = "../.git/"; | ||
442 | string gitRefPointerPath = gitDir + "HEAD"; | ||
443 | |||
444 | string svnRevisionFileName = "svn_revision"; | ||
445 | string svnFileName = ".svn/entries"; | ||
446 | string manualVersionFileName = ".version"; | ||
447 | string inputLine; | ||
448 | int strcmp; | ||
449 | |||
450 | if (File.Exists(manualVersionFileName)) | ||
451 | { | ||
452 | using (StreamReader CommitFile = File.OpenText(manualVersionFileName)) | ||
453 | buildVersion = CommitFile.ReadLine(); | ||
454 | |||
455 | m_version += buildVersion ?? ""; | ||
456 | } | ||
457 | else if (File.Exists(gitRefPointerPath)) | ||
458 | { | ||
459 | // m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath); | ||
460 | |||
461 | string rawPointer = ""; | ||
462 | |||
463 | using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) | ||
464 | rawPointer = pointerFile.ReadLine(); | ||
465 | |||
466 | // m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer); | ||
467 | |||
468 | Match m = Regex.Match(rawPointer, "^ref: (.+)$"); | ||
469 | |||
470 | if (m.Success) | ||
471 | { | ||
472 | // m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value); | ||
473 | |||
474 | string gitRef = m.Groups[1].Value; | ||
475 | string gitRefPath = gitDir + gitRef; | ||
476 | if (File.Exists(gitRefPath)) | ||
477 | { | ||
478 | // m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath); | ||
479 | |||
480 | using (StreamReader refFile = File.OpenText(gitRefPath)) | ||
481 | { | ||
482 | string gitHash = refFile.ReadLine(); | ||
483 | m_version += gitHash.Substring(0, 7); | ||
484 | } | ||
485 | } | ||
486 | } | ||
487 | } | ||
488 | else | ||
489 | { | ||
490 | // Remove the else logic when subversion mirror is no longer used | ||
491 | if (File.Exists(svnRevisionFileName)) | ||
492 | { | ||
493 | StreamReader RevisionFile = File.OpenText(svnRevisionFileName); | ||
494 | buildVersion = RevisionFile.ReadLine(); | ||
495 | buildVersion.Trim(); | ||
496 | RevisionFile.Close(); | ||
497 | } | ||
498 | |||
499 | if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName)) | ||
500 | { | ||
501 | StreamReader EntriesFile = File.OpenText(svnFileName); | ||
502 | inputLine = EntriesFile.ReadLine(); | ||
503 | while (inputLine != null) | ||
504 | { | ||
505 | // using the dir svn revision at the top of entries file | ||
506 | strcmp = String.Compare(inputLine, "dir"); | ||
507 | if (strcmp == 0) | ||
508 | { | ||
509 | buildVersion = EntriesFile.ReadLine(); | ||
510 | break; | ||
511 | } | ||
512 | else | ||
513 | { | ||
514 | inputLine = EntriesFile.ReadLine(); | ||
515 | } | ||
516 | } | ||
517 | EntriesFile.Close(); | ||
518 | } | ||
519 | |||
520 | m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); | ||
521 | } | ||
522 | } | ||
523 | 347 | ||
524 | protected void CreatePIDFile(string path) | 348 | protected void CreatePIDFile(string path) |
525 | { | 349 | { |