From 8cb5ec5fdd21ac3ace385d67145dad8d462ebcb6 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 31 May 2008 20:35:12 +0000 Subject: [PATCH] * Make version information common to all servers * Now all servers respond to the "show version" command on the console --- .../Framework/Servers/BaseOpenSimServer.cs | 82 +++++++++++++++++++ .../Servers}/VersionInfo.cs | 4 +- OpenSim/Region/Application/Application.cs | 1 + OpenSim/Region/Application/OpenSimMain.cs | 71 +--------------- .../Region/Application/OpenSimMainConsole.cs | 12 --- .../ClientStack/LindenUDP/LLClientView.cs | 2 +- 6 files changed, 89 insertions(+), 83 deletions(-) rename OpenSim/{Region/Application => Framework/Servers}/VersionInfo.cs (90%) diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 60c688352d..0205e388cf 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -26,6 +26,7 @@ */ using System; +using System.IO; using OpenSim.Framework.Console; using OpenSim.Framework.Statistics; @@ -37,7 +38,16 @@ namespace OpenSim.Framework.Servers public abstract class BaseOpenSimServer { protected ConsoleBase m_console; + + /// + /// Time at which this server was started + /// protected DateTime m_startuptime; + + /// + /// Server version information. Usually VersionInfo + information about svn revision, operating system, etc. + /// + protected string m_version; protected BaseHttpServer m_httpServer; public BaseHttpServer HttpServer @@ -53,6 +63,11 @@ namespace OpenSim.Framework.Servers public BaseOpenSimServer() { m_startuptime = DateTime.Now; + + m_version = VersionInfo.Version; + + // FIXME: This should probably occur in a startup method common for all the servers. + EnhanceVersionInformation(); } /// @@ -64,6 +79,7 @@ namespace OpenSim.Framework.Servers { m_console.Close(); } + Environment.Exit(0); } @@ -120,6 +136,10 @@ namespace OpenSim.Framework.Servers Notice("Server has been running since " + m_startuptime.DayOfWeek + ", " + m_startuptime.ToString()); Notice("That is an elapsed time of " + (DateTime.Now - m_startuptime).ToString()); break; + + case "version": + m_console.Notice("This is " + m_version); + break; } } @@ -136,5 +156,67 @@ namespace OpenSim.Framework.Servers } } + /// + /// Enhance the version string with extra information if it's available. + /// + protected void EnhanceVersionInformation() + { + string buildVersion = string.Empty; + + // Add subversion revision information if available + // FIXME: Making an assumption about the directory we're currently in - we do this all over the place + // elsewhere as well + string svnFileName = "../.svn/entries"; + string inputLine; + int strcmp; + + if (File.Exists(svnFileName)) + { + StreamReader EntriesFile = File.OpenText(svnFileName); + inputLine = EntriesFile.ReadLine(); + while (inputLine != null) + { + // using the dir svn revision at the top of entries file + strcmp = String.Compare(inputLine, "dir"); + if (strcmp == 0) + { + buildVersion = EntriesFile.ReadLine(); + break; + } + else + { + inputLine = EntriesFile.ReadLine(); + } + } + EntriesFile.Close(); + } + + if (!string.IsNullOrEmpty(buildVersion)) + { + m_version += ", SVN build r" + buildVersion; + } + else + { + m_version += ", SVN build revision not available"; + } + + // Add operating system information if available + string OSString = ""; + + if (System.Environment.OSVersion.Platform != PlatformID.Unix) + { + OSString = System.Environment.OSVersion.ToString(); + } + else + { + OSString = Util.ReadEtcIssue(); + } + if (OSString.Length > 45) + { + OSString = OSString.Substring(0, 45); + } + + m_version += ", OS " + OSString; + } } } diff --git a/OpenSim/Region/Application/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs similarity index 90% rename from OpenSim/Region/Application/VersionInfo.cs rename to OpenSim/Framework/Servers/VersionInfo.cs index 5e291f1acd..5bd78e7270 100644 --- a/OpenSim/Region/Application/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -28,10 +28,10 @@ namespace OpenSim { /// - /// Exists purely to hold version information. + /// This is the OpenSim version string. Change this if you are releasing a new OpenSim version. /// public class VersionInfo { - public static string Version = "trunk (post 0.5.7)"; + public readonly static string Version = "OpenSimulator trunk (post 0.5.7)"; } } diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index b2c710aae3..9aa885f825 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -98,6 +98,7 @@ namespace OpenSim } private static bool _IsHandlingException = false; // Make sure we don't go recursive on ourself + /// /// Global exception handler -- all unhandlet exceptions end up here :) /// diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index d790e41ecb..03dbf781ac 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -54,11 +54,6 @@ namespace OpenSim { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - /// - /// Holds a human readable build version for this server. - /// - protected string buildVersion; - protected string proxyUrl; protected int proxyOffset = 0; @@ -358,73 +353,12 @@ namespace OpenSim Environment.Exit(0); } - /// - /// Enhance the version string with extra information if it's available. - /// - protected void EnhanceVersionInformation() - { - // Add subversion revision information if available - string svnFileName = "../.svn/entries"; - string inputLine; - int strcmp; - - if (File.Exists(svnFileName)) - { - StreamReader EntriesFile = File.OpenText(svnFileName); - inputLine = EntriesFile.ReadLine(); - while (inputLine != null) - { - // using the dir svn revision at the top of entries file - strcmp = String.Compare(inputLine, "dir"); - if (strcmp == 0) - { - buildVersion = EntriesFile.ReadLine(); - break; - } - else - { - inputLine = EntriesFile.ReadLine(); - } - } - EntriesFile.Close(); - } - - if (!string.IsNullOrEmpty(buildVersion)) - { - VersionInfo.Version += ", SVN build r" + buildVersion; - } - else - { - VersionInfo.Version += ", SVN build revision not available"; - } - - // Add operating system information if available - string OSString = ""; - - if (System.Environment.OSVersion.Platform != PlatformID.Unix) - { - OSString = System.Environment.OSVersion.ToString(); - } - else - { - OSString = Util.ReadEtcIssue(); - } - if (OSString.Length > 45) - { - OSString = OSString.Substring(0, 45); - } - - VersionInfo.Version += ", OS " + OSString; - } - /// /// Performs initialisation of the scene, such as loading configuration from disk. /// protected void InternalStartUp() { - EnhanceVersionInformation(); - - m_log.Info("[STARTUP]: OpenSim version: " + VersionInfo.Version + "\n"); + m_log.Info("[STARTUP]: Version " + m_version + "\n"); m_stats = StatsManager.StartCollectingSimExtraStats(); @@ -658,13 +592,14 @@ namespace OpenSim new Scene(regionInfo, circuitManager, m_commsManager, sceneGridService, m_assetCache, storageManager, m_httpServer, m_moduleLoader, m_dumpAssetsToFile, m_physicalPrim, m_see_into_region_from_neighbor, m_config, - VersionInfo.Version); + m_version); } public void handleRestartRegion(RegionInfo whichRegion) { m_log.Error("[OPENSIM MAIN]: Got restart signal from SceneManager"); + // Shutting down the client server bool foundClientServer = false; int clientServerElement = 0; diff --git a/OpenSim/Region/Application/OpenSimMainConsole.cs b/OpenSim/Region/Application/OpenSimMainConsole.cs index 7b1b4770bb..467db14877 100644 --- a/OpenSim/Region/Application/OpenSimMainConsole.cs +++ b/OpenSim/Region/Application/OpenSimMainConsole.cs @@ -253,7 +253,6 @@ namespace OpenSim m_console.Notice("show assets - show state of asset cache."); m_console.Notice("show users - show info about connected users."); m_console.Notice("show modules - shows info about loaded modules."); - m_console.Notice("show version - show the running build version."); m_console.Notice("show regions - show running region information."); m_console.Notice("threads - list threads"); m_console.Notice("config set section field value - set a config value"); @@ -661,17 +660,6 @@ namespace OpenSim scene.RegionInfo.RegionLocY); }); break; - - case "version": - if (!string.IsNullOrEmpty(buildVersion)) - { - m_console.Notice("The build version is: r" + buildVersion); - } - else - { - m_console.Notice("The build version is not available"); - } - break; } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 6a912e5ffe..8b5ecb7e7f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -366,7 +366,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { m_moneyBalance = 1000; - m_channelVersion = Helpers.StringToField("OpenSimulator Server " + scene.GetSimulatorVersion()); + m_channelVersion = Helpers.StringToField(scene.GetSimulatorVersion()); InitDefaultAnimations();