diff options
author | ubit | 2012-12-03 21:26:36 +0100 |
---|---|---|
committer | ubit | 2012-12-03 21:26:36 +0100 |
commit | 5d4b7d537d872d27c394402d3483c2a9bd2153f0 (patch) | |
tree | 39aae50386555bf024700314fb7bee5121a9d683 /OpenSim/Server/Base | |
parent | Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork (diff) | |
parent | Merge branch 'avination' into ubitwork (diff) | |
download | opensim-SC-5d4b7d537d872d27c394402d3483c2a9bd2153f0.zip opensim-SC-5d4b7d537d872d27c394402d3483c2a9bd2153f0.tar.gz opensim-SC-5d4b7d537d872d27c394402d3483c2a9bd2153f0.tar.bz2 opensim-SC-5d4b7d537d872d27c394402d3483c2a9bd2153f0.tar.xz |
Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
Diffstat (limited to 'OpenSim/Server/Base')
-rw-r--r-- | OpenSim/Server/Base/HttpServerBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Server/Base/Properties/AssemblyInfo.cs | 33 | ||||
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 138 |
3 files changed, 51 insertions, 122 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 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using 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 b137c05..5b23149 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Threading; | 32 | using System.Threading; |
@@ -33,6 +34,7 @@ using System.Text; | |||
33 | using System.Xml; | 34 | using System.Xml; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Servers; | ||
36 | using log4net; | 38 | using log4net; |
37 | using log4net.Config; | 39 | using log4net.Config; |
38 | using log4net.Appender; | 40 | using log4net.Appender; |
@@ -42,7 +44,7 @@ using Nini.Config; | |||
42 | 44 | ||
43 | namespace OpenSim.Server.Base | 45 | namespace OpenSim.Server.Base |
44 | { | 46 | { |
45 | public class ServicesServerBase | 47 | public class ServicesServerBase : ServerBase |
46 | { | 48 | { |
47 | // Logger | 49 | // Logger |
48 | // | 50 | // |
@@ -54,26 +56,13 @@ namespace OpenSim.Server.Base | |||
54 | // | 56 | // |
55 | protected string[] m_Arguments; | 57 | protected string[] m_Arguments; |
56 | 58 | ||
57 | // Configuration | ||
58 | // | ||
59 | protected IConfigSource m_Config = null; | ||
60 | |||
61 | public IConfigSource Config | ||
62 | { | ||
63 | get { return m_Config; } | ||
64 | } | ||
65 | |||
66 | // Run flag | 59 | // Run flag |
67 | // | 60 | // |
68 | private bool m_Running = true; | 61 | private bool m_Running = true; |
69 | 62 | ||
70 | // PID file | ||
71 | // | ||
72 | private string m_pidFile = String.Empty; | ||
73 | |||
74 | // Handle all the automagical stuff | 63 | // Handle all the automagical stuff |
75 | // | 64 | // |
76 | public ServicesServerBase(string prompt, string[] args) | 65 | public ServicesServerBase(string prompt, string[] args) : base() |
77 | { | 66 | { |
78 | // Save raw arguments | 67 | // Save raw arguments |
79 | // | 68 | // |
@@ -120,11 +109,11 @@ namespace OpenSim.Server.Base | |||
120 | configUri.Scheme == Uri.UriSchemeHttp) | 109 | configUri.Scheme == Uri.UriSchemeHttp) |
121 | { | 110 | { |
122 | XmlReader r = XmlReader.Create(iniFile); | 111 | XmlReader r = XmlReader.Create(iniFile); |
123 | m_Config = new XmlConfigSource(r); | 112 | Config = new XmlConfigSource(r); |
124 | } | 113 | } |
125 | else | 114 | else |
126 | { | 115 | { |
127 | m_Config = new IniConfigSource(iniFile); | 116 | Config = new IniConfigSource(iniFile); |
128 | } | 117 | } |
129 | } | 118 | } |
130 | catch (Exception e) | 119 | catch (Exception e) |
@@ -136,13 +125,13 @@ namespace OpenSim.Server.Base | |||
136 | // Merge the configuration from the command line into the | 125 | // Merge the configuration from the command line into the |
137 | // loaded file | 126 | // loaded file |
138 | // | 127 | // |
139 | m_Config.Merge(argvConfig); | 128 | Config.Merge(argvConfig); |
140 | 129 | ||
141 | // Refresh the startupConfig post merge | 130 | // Refresh the startupConfig post merge |
142 | // | 131 | // |
143 | if (m_Config.Configs["Startup"] != null) | 132 | if (Config.Configs["Startup"] != null) |
144 | { | 133 | { |
145 | startupConfig = m_Config.Configs["Startup"]; | 134 | startupConfig = Config.Configs["Startup"]; |
146 | } | 135 | } |
147 | 136 | ||
148 | prompt = startupConfig.GetString("Prompt", prompt); | 137 | prompt = startupConfig.GetString("Prompt", prompt); |
@@ -172,6 +161,8 @@ namespace OpenSim.Server.Base | |||
172 | MainConsole.Instance = new LocalConsole(prompt); | 161 | MainConsole.Instance = new LocalConsole(prompt); |
173 | } | 162 | } |
174 | 163 | ||
164 | m_console = MainConsole.Instance; | ||
165 | |||
175 | // Configure the appenders for log4net | 166 | // Configure the appenders for log4net |
176 | // | 167 | // |
177 | OpenSimAppender consoleAppender = null; | 168 | OpenSimAppender consoleAppender = null; |
@@ -187,54 +178,15 @@ namespace OpenSim.Server.Base | |||
187 | XmlConfigurator.Configure(); | 178 | XmlConfigurator.Configure(); |
188 | } | 179 | } |
189 | 180 | ||
190 | ILoggerRepository repository = LogManager.GetRepository(); | 181 | RegisterCommonAppenders(startupConfig); |
191 | IAppender[] appenders = repository.GetAppenders(); | ||
192 | |||
193 | foreach (IAppender appender in appenders) | ||
194 | { | ||
195 | if (appender.Name == "Console") | ||
196 | { | ||
197 | consoleAppender = (OpenSimAppender)appender; | ||
198 | } | ||
199 | if (appender.Name == "LogFileAppender") | ||
200 | { | ||
201 | fileAppender = (FileAppender)appender; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | if (consoleAppender == null) | ||
206 | { | ||
207 | System.Console.WriteLine("No console appender found. Server can't start"); | ||
208 | Thread.CurrentThread.Abort(); | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | consoleAppender.Console = (ConsoleBase)MainConsole.Instance; | ||
213 | |||
214 | if (null == consoleAppender.Threshold) | ||
215 | consoleAppender.Threshold = Level.All; | ||
216 | } | ||
217 | |||
218 | // Set log file | ||
219 | // | ||
220 | if (fileAppender != null) | ||
221 | { | ||
222 | if (startupConfig != null) | ||
223 | { | ||
224 | string cfgFileName = startupConfig.GetString("logfile", null); | ||
225 | if (cfgFileName != null) | ||
226 | { | ||
227 | fileAppender.File = cfgFileName; | ||
228 | fileAppender.ActivateOptions(); | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | 182 | ||
233 | if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) | 183 | if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) |
234 | { | 184 | { |
235 | CreatePIDFile(startupConfig.GetString("PIDFile")); | 185 | CreatePIDFile(startupConfig.GetString("PIDFile")); |
236 | } | 186 | } |
237 | 187 | ||
188 | RegisterCommonCommands(); | ||
189 | |||
238 | // Register the quit command | 190 | // Register the quit command |
239 | // | 191 | // |
240 | MainConsole.Instance.Commands.AddCommand("General", false, "quit", | 192 | MainConsole.Instance.Commands.AddCommand("General", false, "quit", |
@@ -244,12 +196,6 @@ namespace OpenSim.Server.Base | |||
244 | MainConsole.Instance.Commands.AddCommand("General", false, "shutdown", | 196 | MainConsole.Instance.Commands.AddCommand("General", false, "shutdown", |
245 | "shutdown", | 197 | "shutdown", |
246 | "Quit the application", HandleQuit); | 198 | "Quit the application", HandleQuit); |
247 | |||
248 | // Register a command to read other commands from a file | ||
249 | MainConsole.Instance.Commands.AddCommand("General", false, "command-script", | ||
250 | "command-script <script>", | ||
251 | "Run a command script from file", HandleScript); | ||
252 | |||
253 | 199 | ||
254 | // Allow derived classes to perform initialization that | 200 | // Allow derived classes to perform initialization that |
255 | // needs to be done after the console has opened | 201 | // needs to be done after the console has opened |
@@ -276,8 +222,8 @@ namespace OpenSim.Server.Base | |||
276 | } | 222 | } |
277 | } | 223 | } |
278 | 224 | ||
279 | if (m_pidFile != String.Empty) | 225 | RemovePIDFile(); |
280 | File.Delete(m_pidFile); | 226 | |
281 | return 0; | 227 | return 0; |
282 | } | 228 | } |
283 | 229 | ||
@@ -285,43 +231,9 @@ namespace OpenSim.Server.Base | |||
285 | { | 231 | { |
286 | m_Running = false; | 232 | m_Running = false; |
287 | m_log.Info("[CONSOLE] Quitting"); | 233 | m_log.Info("[CONSOLE] Quitting"); |
288 | } | ||
289 | |||
290 | protected virtual void HandleScript(string module, string[] parms) | ||
291 | { | ||
292 | if (parms.Length != 2) | ||
293 | { | ||
294 | return; | ||
295 | } | ||
296 | RunCommandScript(parms[1]); | ||
297 | } | ||
298 | |||
299 | /// <summary> | ||
300 | /// Run an optional startup list of commands | ||
301 | /// </summary> | ||
302 | /// <param name="fileName"></param> | ||
303 | private void RunCommandScript(string fileName) | ||
304 | { | ||
305 | if (File.Exists(fileName)) | ||
306 | { | ||
307 | m_log.Info("[COMMANDFILE]: Running " + fileName); | ||
308 | 234 | ||
309 | using (StreamReader readFile = File.OpenText(fileName)) | ||
310 | { | ||
311 | string currentCommand; | ||
312 | while ((currentCommand = readFile.ReadLine()) != null) | ||
313 | { | ||
314 | if (currentCommand != String.Empty) | ||
315 | { | ||
316 | m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); | ||
317 | MainConsole.Instance.RunCommand(currentCommand); | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | } | ||
322 | } | 235 | } |
323 | 236 | ||
324 | |||
325 | protected virtual void ReadConfig() | 237 | protected virtual void ReadConfig() |
326 | { | 238 | { |
327 | } | 239 | } |
@@ -329,21 +241,5 @@ namespace OpenSim.Server.Base | |||
329 | protected virtual void Initialise() | 241 | protected virtual void Initialise() |
330 | { | 242 | { |
331 | } | 243 | } |
332 | |||
333 | protected void CreatePIDFile(string path) | ||
334 | { | ||
335 | try | ||
336 | { | ||
337 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
338 | FileStream fs = File.Create(path); | ||
339 | Byte[] buf = Encoding.ASCII.GetBytes(pidstring); | ||
340 | fs.Write(buf, 0, buf.Length); | ||
341 | fs.Close(); | ||
342 | m_pidFile = path; | ||
343 | } | ||
344 | catch (Exception) | ||
345 | { | ||
346 | } | ||
347 | } | ||
348 | } | 244 | } |
349 | } | 245 | } \ No newline at end of file |