diff options
author | Justin Clarke Casey | 2008-05-31 20:35:12 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-05-31 20:35:12 +0000 |
commit | 8cb5ec5fdd21ac3ace385d67145dad8d462ebcb6 (patch) | |
tree | c19c5ea998f73ea195542ce3650782baa226e972 /OpenSim/Framework/Servers/BaseOpenSimServer.cs | |
parent | * Made UpdateUserCurrentRegion a bit more forgiving. (diff) | |
download | opensim-SC-8cb5ec5fdd21ac3ace385d67145dad8d462ebcb6.zip opensim-SC-8cb5ec5fdd21ac3ace385d67145dad8d462ebcb6.tar.gz opensim-SC-8cb5ec5fdd21ac3ace385d67145dad8d462ebcb6.tar.bz2 opensim-SC-8cb5ec5fdd21ac3ace385d67145dad8d462ebcb6.tar.xz |
* Make version information common to all servers
* Now all servers respond to the "show version" command on the console
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 60c6883..0205e38 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
29 | using OpenSim.Framework.Console; | 30 | using OpenSim.Framework.Console; |
30 | using OpenSim.Framework.Statistics; | 31 | using OpenSim.Framework.Statistics; |
31 | 32 | ||
@@ -37,7 +38,16 @@ namespace OpenSim.Framework.Servers | |||
37 | public abstract class BaseOpenSimServer | 38 | public abstract class BaseOpenSimServer |
38 | { | 39 | { |
39 | protected ConsoleBase m_console; | 40 | protected ConsoleBase m_console; |
41 | |||
42 | /// <summary> | ||
43 | /// Time at which this server was started | ||
44 | /// </summary> | ||
40 | protected DateTime m_startuptime; | 45 | protected DateTime m_startuptime; |
46 | |||
47 | /// <summary> | ||
48 | /// Server version information. Usually VersionInfo + information about svn revision, operating system, etc. | ||
49 | /// </summary> | ||
50 | protected string m_version; | ||
41 | 51 | ||
42 | protected BaseHttpServer m_httpServer; | 52 | protected BaseHttpServer m_httpServer; |
43 | public BaseHttpServer HttpServer | 53 | public BaseHttpServer HttpServer |
@@ -53,6 +63,11 @@ namespace OpenSim.Framework.Servers | |||
53 | public BaseOpenSimServer() | 63 | public BaseOpenSimServer() |
54 | { | 64 | { |
55 | m_startuptime = DateTime.Now; | 65 | m_startuptime = DateTime.Now; |
66 | |||
67 | m_version = VersionInfo.Version; | ||
68 | |||
69 | // FIXME: This should probably occur in a startup method common for all the servers. | ||
70 | EnhanceVersionInformation(); | ||
56 | } | 71 | } |
57 | 72 | ||
58 | /// <summary> | 73 | /// <summary> |
@@ -64,6 +79,7 @@ namespace OpenSim.Framework.Servers | |||
64 | { | 79 | { |
65 | m_console.Close(); | 80 | m_console.Close(); |
66 | } | 81 | } |
82 | |||
67 | Environment.Exit(0); | 83 | Environment.Exit(0); |
68 | } | 84 | } |
69 | 85 | ||
@@ -120,6 +136,10 @@ namespace OpenSim.Framework.Servers | |||
120 | Notice("Server has been running since " + m_startuptime.DayOfWeek + ", " + m_startuptime.ToString()); | 136 | Notice("Server has been running since " + m_startuptime.DayOfWeek + ", " + m_startuptime.ToString()); |
121 | Notice("That is an elapsed time of " + (DateTime.Now - m_startuptime).ToString()); | 137 | Notice("That is an elapsed time of " + (DateTime.Now - m_startuptime).ToString()); |
122 | break; | 138 | break; |
139 | |||
140 | case "version": | ||
141 | m_console.Notice("This is " + m_version); | ||
142 | break; | ||
123 | } | 143 | } |
124 | } | 144 | } |
125 | 145 | ||
@@ -136,5 +156,67 @@ namespace OpenSim.Framework.Servers | |||
136 | } | 156 | } |
137 | } | 157 | } |
138 | 158 | ||
159 | /// <summary> | ||
160 | /// Enhance the version string with extra information if it's available. | ||
161 | /// </summary> | ||
162 | protected void EnhanceVersionInformation() | ||
163 | { | ||
164 | string buildVersion = string.Empty; | ||
165 | |||
166 | // Add subversion revision information if available | ||
167 | // FIXME: Making an assumption about the directory we're currently in - we do this all over the place | ||
168 | // elsewhere as well | ||
169 | string svnFileName = "../.svn/entries"; | ||
170 | string inputLine; | ||
171 | int strcmp; | ||
172 | |||
173 | if (File.Exists(svnFileName)) | ||
174 | { | ||
175 | StreamReader EntriesFile = File.OpenText(svnFileName); | ||
176 | inputLine = EntriesFile.ReadLine(); | ||
177 | while (inputLine != null) | ||
178 | { | ||
179 | // using the dir svn revision at the top of entries file | ||
180 | strcmp = String.Compare(inputLine, "dir"); | ||
181 | if (strcmp == 0) | ||
182 | { | ||
183 | buildVersion = EntriesFile.ReadLine(); | ||
184 | break; | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | inputLine = EntriesFile.ReadLine(); | ||
189 | } | ||
190 | } | ||
191 | EntriesFile.Close(); | ||
192 | } | ||
193 | |||
194 | if (!string.IsNullOrEmpty(buildVersion)) | ||
195 | { | ||
196 | m_version += ", SVN build r" + buildVersion; | ||
197 | } | ||
198 | else | ||
199 | { | ||
200 | m_version += ", SVN build revision not available"; | ||
201 | } | ||
202 | |||
203 | // Add operating system information if available | ||
204 | string OSString = ""; | ||
205 | |||
206 | if (System.Environment.OSVersion.Platform != PlatformID.Unix) | ||
207 | { | ||
208 | OSString = System.Environment.OSVersion.ToString(); | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | OSString = Util.ReadEtcIssue(); | ||
213 | } | ||
214 | if (OSString.Length > 45) | ||
215 | { | ||
216 | OSString = OSString.Substring(0, 45); | ||
217 | } | ||
218 | |||
219 | m_version += ", OS " + OSString; | ||
220 | } | ||
139 | } | 221 | } |
140 | } | 222 | } |