* Make version information common to all servers

* Now all servers respond to the "show version" command on the console
0.6.0-stable
Justin Clarke Casey 2008-05-31 20:35:12 +00:00
parent ce234eee37
commit 8cb5ec5fdd
6 changed files with 89 additions and 83 deletions

View File

@ -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;
/// <summary>
/// Time at which this server was started
/// </summary>
protected DateTime m_startuptime;
/// <summary>
/// Server version information. Usually VersionInfo + information about svn revision, operating system, etc.
/// </summary>
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();
}
/// <summary>
@ -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
}
}
/// <summary>
/// Enhance the version string with extra information if it's available.
/// </summary>
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;
}
}
}

View File

@ -28,10 +28,10 @@
namespace OpenSim
{
/// <summary>
/// Exists purely to hold version information.
/// This is the OpenSim version string. Change this if you are releasing a new OpenSim version.
/// </summary>
public class VersionInfo
{
public static string Version = "trunk (post 0.5.7)";
public readonly static string Version = "OpenSimulator trunk (post 0.5.7)";
}
}

View File

@ -98,6 +98,7 @@ namespace OpenSim
}
private static bool _IsHandlingException = false; // Make sure we don't go recursive on ourself
/// <summary>
/// Global exception handler -- all unhandlet exceptions end up here :)
/// </summary>

View File

@ -54,11 +54,6 @@ namespace OpenSim
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Holds a human readable build version for this server.
/// </summary>
protected string buildVersion;
protected string proxyUrl;
protected int proxyOffset = 0;
@ -358,73 +353,12 @@ namespace OpenSim
Environment.Exit(0);
}
/// <summary>
/// Enhance the version string with extra information if it's available.
/// </summary>
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;
}
/// <summary>
/// Performs initialisation of the scene, such as loading configuration from disk.
/// </summary>
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;

View File

@ -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;
}
}

View File

@ -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();