aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Base
diff options
context:
space:
mode:
authorBlueWall2012-11-25 17:03:14 -0500
committerBlueWall2012-11-25 17:03:14 -0500
commitc754003944d0166bf50b4f94b0c0eea642503bb0 (patch)
treedfa1c2020d5500d510519d5b2b3236600692f277 /OpenSim/Server/Base
parentMerge branch 'master' into connector_plugin (diff)
parentCombine TestDeleteSceneObjectAsync() with TestDeRezSceneObject() as they are ... (diff)
downloadopensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.zip
opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.gz
opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.bz2
opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.xz
Merge branch 'master' into connector_plugin
Conflicts: OpenSim/Server/Base/ServicesServerBase.cs
Diffstat (limited to 'OpenSim/Server/Base')
-rw-r--r--OpenSim/Server/Base/HttpServerBase.cs2
-rw-r--r--OpenSim/Server/Base/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs175
3 files changed, 49 insertions, 161 deletions
diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs
index 29b1c00..954783c 100644
--- a/OpenSim/Server/Base/HttpServerBase.cs
+++ b/OpenSim/Server/Base/HttpServerBase.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Server.Base
52 52
53 protected override void ReadConfig() 53 protected override void ReadConfig()
54 { 54 {
55 IConfig networkConfig = m_Config.Configs["Network"]; 55 IConfig networkConfig = Config.Configs["Network"];
56 56
57 if (networkConfig == null) 57 if (networkConfig == null)
58 { 58 {
diff --git a/OpenSim/Server/Base/Properties/AssemblyInfo.cs b/OpenSim/Server/Base/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..4bbe358
--- /dev/null
+++ b/OpenSim/Server/Base/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.Server.Base")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("http://opensimulator.org")]
12[assembly: AssemblyProduct("OpenSim")]
13[assembly: AssemblyCopyright("OpenSimulator developers")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("8fbd5035-0dbc-4b9a-ad1a-a7567f254ea9")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("0.7.5.*")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 2f12288..ecd69b0 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -34,6 +34,7 @@ using System.Text;
34using System.Xml; 34using System.Xml;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Servers;
37using log4net; 38using log4net;
38using log4net.Config; 39using log4net.Config;
39using log4net.Appender; 40using log4net.Appender;
@@ -43,7 +44,7 @@ using Nini.Config;
43 44
44namespace OpenSim.Server.Base 45namespace OpenSim.Server.Base
45{ 46{
46 public class ServicesServerBase 47 public class ServicesServerBase : ServerBase
47 { 48 {
48 // Logger 49 // Logger
49 // 50 //
@@ -55,15 +56,6 @@ namespace OpenSim.Server.Base
55 // 56 //
56 protected string[] m_Arguments; 57 protected string[] m_Arguments;
57 58
58 // Configuration
59 //
60 protected IConfigSource m_Config = null;
61
62 public IConfigSource Config
63 {
64 get { return m_Config; }
65 }
66
67 public string ConfigDirectory 59 public string ConfigDirectory
68 { 60 {
69 get; 61 get;
@@ -74,21 +66,10 @@ namespace OpenSim.Server.Base
74 // 66 //
75 private bool m_Running = true; 67 private bool m_Running = true;
76 68
77 // PID file
78 //
79 private string m_pidFile = String.Empty;
80
81 /// <summary>
82 /// Time at which this server was started
83 /// </summary>
84 protected DateTime m_startuptime;
85
86 // Handle all the automagical stuff 69 // Handle all the automagical stuff
87 // 70 //
88 public ServicesServerBase(string prompt, string[] args) 71 public ServicesServerBase(string prompt, string[] args) : base()
89 { 72 {
90 m_startuptime = DateTime.Now;
91
92 // Save raw arguments 73 // Save raw arguments
93 // 74 //
94 m_Arguments = args; 75 m_Arguments = args;
@@ -134,11 +115,11 @@ namespace OpenSim.Server.Base
134 configUri.Scheme == Uri.UriSchemeHttp) 115 configUri.Scheme == Uri.UriSchemeHttp)
135 { 116 {
136 XmlReader r = XmlReader.Create(iniFile); 117 XmlReader r = XmlReader.Create(iniFile);
137 m_Config = new XmlConfigSource(r); 118 Config = new XmlConfigSource(r);
138 } 119 }
139 else 120 else
140 { 121 {
141 m_Config = new IniConfigSource(iniFile); 122 Config = new IniConfigSource(iniFile);
142 } 123 }
143 } 124 }
144 catch (Exception e) 125 catch (Exception e)
@@ -150,13 +131,13 @@ namespace OpenSim.Server.Base
150 // Merge the configuration from the command line into the 131 // Merge the configuration from the command line into the
151 // loaded file 132 // loaded file
152 // 133 //
153 m_Config.Merge(argvConfig); 134 Config.Merge(argvConfig);
154 135
155 // Refresh the startupConfig post merge 136 // Refresh the startupConfig post merge
156 // 137 //
157 if (m_Config.Configs["Startup"] != null) 138 if (Config.Configs["Startup"] != null)
158 { 139 {
159 startupConfig = m_Config.Configs["Startup"]; 140 startupConfig = Config.Configs["Startup"];
160 } 141 }
161 142
162 ConfigDirectory = startupConfig.GetString("ConfigDirectory", "."); 143 ConfigDirectory = startupConfig.GetString("ConfigDirectory", ".");
@@ -188,6 +169,8 @@ namespace OpenSim.Server.Base
188 MainConsole.Instance = new LocalConsole(prompt); 169 MainConsole.Instance = new LocalConsole(prompt);
189 } 170 }
190 171
172 m_console = MainConsole.Instance;
173
191 // Configure the appenders for log4net 174 // Configure the appenders for log4net
192 // 175 //
193 OpenSimAppender consoleAppender = null; 176 OpenSimAppender consoleAppender = null;
@@ -203,54 +186,15 @@ namespace OpenSim.Server.Base
203 XmlConfigurator.Configure(); 186 XmlConfigurator.Configure();
204 } 187 }
205 188
206 ILoggerRepository repository = LogManager.GetRepository(); 189 RegisterCommonAppenders(startupConfig);
207 IAppender[] appenders = repository.GetAppenders();
208
209 foreach (IAppender appender in appenders)
210 {
211 if (appender.Name == "Console")
212 {
213 consoleAppender = (OpenSimAppender)appender;
214 }
215 if (appender.Name == "LogFileAppender")
216 {
217 fileAppender = (FileAppender)appender;
218 }
219 }
220
221 if (consoleAppender == null)
222 {
223 System.Console.WriteLine("No console appender found. Server can't start");
224 Thread.CurrentThread.Abort();
225 }
226 else
227 {
228 consoleAppender.Console = (ConsoleBase)MainConsole.Instance;
229
230 if (null == consoleAppender.Threshold)
231 consoleAppender.Threshold = Level.All;
232 }
233
234 // Set log file
235 //
236 if (fileAppender != null)
237 {
238 if (startupConfig != null)
239 {
240 string cfgFileName = startupConfig.GetString("logfile", null);
241 if (cfgFileName != null)
242 {
243 fileAppender.File = cfgFileName;
244 fileAppender.ActivateOptions();
245 }
246 }
247 }
248 190
249 if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) 191 if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty)
250 { 192 {
251 CreatePIDFile(startupConfig.GetString("PIDFile")); 193 CreatePIDFile(startupConfig.GetString("PIDFile"));
252 } 194 }
253 195
196 RegisterCommonCommands();
197
254 // Register the quit command 198 // Register the quit command
255 // 199 //
256 MainConsole.Instance.Commands.AddCommand("General", false, "quit", 200 MainConsole.Instance.Commands.AddCommand("General", false, "quit",
@@ -260,16 +204,6 @@ namespace OpenSim.Server.Base
260 MainConsole.Instance.Commands.AddCommand("General", false, "shutdown", 204 MainConsole.Instance.Commands.AddCommand("General", false, "shutdown",
261 "shutdown", 205 "shutdown",
262 "Quit the application", HandleQuit); 206 "Quit the application", HandleQuit);
263
264 // Register a command to read other commands from a file
265 MainConsole.Instance.Commands.AddCommand("General", false, "command-script",
266 "command-script <script>",
267 "Run a command script from file", HandleScript);
268
269 MainConsole.Instance.Commands.AddCommand("General", false, "show uptime",
270 "show uptime",
271 "Show server uptime", HandleShow);
272
273 207
274 // Allow derived classes to perform initialization that 208 // Allow derived classes to perform initialization that
275 // needs to be done after the console has opened 209 // needs to be done after the console has opened
@@ -296,8 +230,8 @@ namespace OpenSim.Server.Base
296 } 230 }
297 } 231 }
298 232
299 if (m_pidFile != String.Empty) 233 RemovePIDFile();
300 File.Delete(m_pidFile); 234
301 return 0; 235 return 0;
302 } 236 }
303 237
@@ -305,43 +239,9 @@ namespace OpenSim.Server.Base
305 { 239 {
306 m_Running = false; 240 m_Running = false;
307 m_log.Info("[CONSOLE] Quitting"); 241 m_log.Info("[CONSOLE] Quitting");
308 }
309 242
310 protected virtual void HandleScript(string module, string[] parms)
311 {
312 if (parms.Length != 2)
313 {
314 return;
315 }
316 RunCommandScript(parms[1]);
317 } 243 }
318 244
319 /// <summary>
320 /// Run an optional startup list of commands
321 /// </summary>
322 /// <param name="fileName"></param>
323 private void RunCommandScript(string fileName)
324 {
325 if (File.Exists(fileName))
326 {
327 m_log.Info("[COMMANDFILE]: Running " + fileName);
328
329 using (StreamReader readFile = File.OpenText(fileName))
330 {
331 string currentCommand;
332 while ((currentCommand = readFile.ReadLine()) != null)
333 {
334 if (currentCommand != String.Empty)
335 {
336 m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
337 MainConsole.Instance.RunCommand(currentCommand);
338 }
339 }
340 }
341 }
342 }
343
344
345 protected virtual void ReadConfig() 245 protected virtual void ReadConfig()
346 { 246 {
347 } 247 }
@@ -349,50 +249,5 @@ namespace OpenSim.Server.Base
349 protected virtual void Initialise() 249 protected virtual void Initialise()
350 { 250 {
351 } 251 }
352
353 protected void CreatePIDFile(string path)
354 {
355 try
356 {
357 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
358 FileStream fs = File.Create(path);
359 Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
360 fs.Write(buf, 0, buf.Length);
361 fs.Close();
362 m_pidFile = path;
363 }
364 catch (Exception)
365 {
366 }
367 }
368
369 public virtual void HandleShow(string module, string[] cmd)
370 {
371 List<string> args = new List<string>(cmd);
372
373 args.RemoveAt(0);
374
375 string[] showParams = args.ToArray();
376
377 switch (showParams[0])
378 {
379 case "uptime":
380 MainConsole.Instance.Output(GetUptimeReport());
381 break;
382 }
383 }
384
385 /// <summary>
386 /// Return a report about the uptime of this server
387 /// </summary>
388 /// <returns></returns>
389 protected string GetUptimeReport()
390 {
391 StringBuilder sb = new StringBuilder(String.Format("Time now is {0}\n", DateTime.Now));
392 sb.Append(String.Format("Server has been running since {0}, {1}\n", m_startuptime.DayOfWeek, m_startuptime));
393 sb.Append(String.Format("That is an elapsed time of {0}\n", DateTime.Now - m_startuptime));
394
395 return sb.ToString();
396 }
397 } 252 }
398} 253}