diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index ecd69b0..1f2c54d 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -34,6 +34,7 @@ using System.Text; | |||
34 | using System.Xml; | 34 | using System.Xml; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Monitoring; | ||
37 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
38 | using log4net; | 39 | using log4net; |
39 | using log4net.Config; | 40 | using log4net.Config; |
@@ -48,9 +49,7 @@ namespace OpenSim.Server.Base | |||
48 | { | 49 | { |
49 | // Logger | 50 | // Logger |
50 | // | 51 | // |
51 | private static readonly ILog m_log = | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | LogManager.GetLogger( | ||
53 | MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | 53 | ||
55 | // Command line args | 54 | // Command line args |
56 | // | 55 | // |
@@ -71,11 +70,9 @@ namespace OpenSim.Server.Base | |||
71 | public ServicesServerBase(string prompt, string[] args) : base() | 70 | public ServicesServerBase(string prompt, string[] args) : base() |
72 | { | 71 | { |
73 | // Save raw arguments | 72 | // Save raw arguments |
74 | // | ||
75 | m_Arguments = args; | 73 | m_Arguments = args; |
76 | 74 | ||
77 | // Read command line | 75 | // Read command line |
78 | // | ||
79 | ArgvConfigSource argvConfig = new ArgvConfigSource(args); | 76 | ArgvConfigSource argvConfig = new ArgvConfigSource(args); |
80 | 77 | ||
81 | argvConfig.AddSwitch("Startup", "console", "c"); | 78 | argvConfig.AddSwitch("Startup", "console", "c"); |
@@ -85,8 +82,9 @@ namespace OpenSim.Server.Base | |||
85 | argvConfig.AddSwitch("Startup", "logconfig", "g"); | 82 | argvConfig.AddSwitch("Startup", "logconfig", "g"); |
86 | 83 | ||
87 | // Automagically create the ini file name | 84 | // Automagically create the ini file name |
88 | // | 85 | string fileName = ""; |
89 | string fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); | 86 | if (Assembly.GetEntryAssembly() != null) |
87 | fileName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location); | ||
90 | string iniFile = fileName + ".ini"; | 88 | string iniFile = fileName + ".ini"; |
91 | string logConfig = null; | 89 | string logConfig = null; |
92 | 90 | ||
@@ -94,19 +92,17 @@ namespace OpenSim.Server.Base | |||
94 | if (startupConfig != null) | 92 | if (startupConfig != null) |
95 | { | 93 | { |
96 | // Check if a file name was given on the command line | 94 | // Check if a file name was given on the command line |
97 | // | ||
98 | iniFile = startupConfig.GetString("inifile", iniFile); | 95 | iniFile = startupConfig.GetString("inifile", iniFile); |
99 | // | 96 | |
100 | // Check if a prompt was given on the command line | 97 | // Check if a prompt was given on the command line |
101 | prompt = startupConfig.GetString("prompt", prompt); | 98 | prompt = startupConfig.GetString("prompt", prompt); |
102 | // | 99 | |
103 | // Check for a Log4Net config file on the command line | 100 | // Check for a Log4Net config file on the command line |
104 | logConfig =startupConfig.GetString("logconfig",logConfig); | 101 | logConfig =startupConfig.GetString("logconfig", logConfig); |
105 | } | 102 | } |
106 | 103 | ||
107 | // Find out of the file name is a URI and remote load it | 104 | // Find out of the file name is a URI and remote load it if possible. |
108 | // if it's possible. Load it as a local file otherwise. | 105 | // Load it as a local file otherwise. |
109 | // | ||
110 | Uri configUri; | 106 | Uri configUri; |
111 | 107 | ||
112 | try | 108 | try |
@@ -128,13 +124,16 @@ namespace OpenSim.Server.Base | |||
128 | Environment.Exit(1); | 124 | Environment.Exit(1); |
129 | } | 125 | } |
130 | 126 | ||
131 | // Merge the configuration from the command line into the | 127 | // Merge OpSys env vars |
132 | // loaded file | 128 | m_log.Info("[CONFIG]: Loading environment variables for Config"); |
133 | // | 129 | Util.MergeEnvironmentToConfig(Config); |
130 | |||
131 | // Merge the configuration from the command line into the loaded file | ||
134 | Config.Merge(argvConfig); | 132 | Config.Merge(argvConfig); |
135 | 133 | ||
134 | Config.ReplaceKeyValues(); | ||
135 | |||
136 | // Refresh the startupConfig post merge | 136 | // Refresh the startupConfig post merge |
137 | // | ||
138 | if (Config.Configs["Startup"] != null) | 137 | if (Config.Configs["Startup"] != null) |
139 | { | 138 | { |
140 | startupConfig = Config.Configs["Startup"]; | 139 | startupConfig = Config.Configs["Startup"]; |
@@ -144,13 +143,10 @@ namespace OpenSim.Server.Base | |||
144 | 143 | ||
145 | prompt = startupConfig.GetString("Prompt", prompt); | 144 | prompt = startupConfig.GetString("Prompt", prompt); |
146 | 145 | ||
147 | // Allow derived classes to load config before the console is | 146 | // Allow derived classes to load config before the console is opened. |
148 | // opened. | ||
149 | // | ||
150 | ReadConfig(); | 147 | ReadConfig(); |
151 | 148 | ||
152 | // Create main console | 149 | // Create main console |
153 | // | ||
154 | string consoleType = "local"; | 150 | string consoleType = "local"; |
155 | if (startupConfig != null) | 151 | if (startupConfig != null) |
156 | consoleType = startupConfig.GetString("console", consoleType); | 152 | consoleType = startupConfig.GetString("console", consoleType); |
@@ -164,18 +160,17 @@ namespace OpenSim.Server.Base | |||
164 | MainConsole.Instance = new RemoteConsole(prompt); | 160 | MainConsole.Instance = new RemoteConsole(prompt); |
165 | ((RemoteConsole)MainConsole.Instance).ReadConfig(Config); | 161 | ((RemoteConsole)MainConsole.Instance).ReadConfig(Config); |
166 | } | 162 | } |
167 | else | 163 | else if (consoleType == "mock") |
164 | { | ||
165 | MainConsole.Instance = new MockConsole(); | ||
166 | } | ||
167 | else if (consoleType == "local") | ||
168 | { | 168 | { |
169 | MainConsole.Instance = new LocalConsole(prompt); | 169 | MainConsole.Instance = new LocalConsole(prompt, startupConfig); |
170 | } | 170 | } |
171 | 171 | ||
172 | m_console = MainConsole.Instance; | 172 | m_console = MainConsole.Instance; |
173 | 173 | ||
174 | // Configure the appenders for log4net | ||
175 | // | ||
176 | OpenSimAppender consoleAppender = null; | ||
177 | FileAppender fileAppender = null; | ||
178 | |||
179 | if (logConfig != null) | 174 | if (logConfig != null) |
180 | { | 175 | { |
181 | FileInfo cfg = new FileInfo(logConfig); | 176 | FileInfo cfg = new FileInfo(logConfig); |
@@ -186,6 +181,7 @@ namespace OpenSim.Server.Base | |||
186 | XmlConfigurator.Configure(); | 181 | XmlConfigurator.Configure(); |
187 | } | 182 | } |
188 | 183 | ||
184 | LogEnvironmentInformation(); | ||
189 | RegisterCommonAppenders(startupConfig); | 185 | RegisterCommonAppenders(startupConfig); |
190 | 186 | ||
191 | if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) | 187 | if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) |
@@ -194,20 +190,10 @@ namespace OpenSim.Server.Base | |||
194 | } | 190 | } |
195 | 191 | ||
196 | RegisterCommonCommands(); | 192 | RegisterCommonCommands(); |
197 | 193 | RegisterCommonComponents(Config); | |
198 | // Register the quit command | ||
199 | // | ||
200 | MainConsole.Instance.Commands.AddCommand("General", false, "quit", | ||
201 | "quit", | ||
202 | "Quit the application", HandleQuit); | ||
203 | |||
204 | MainConsole.Instance.Commands.AddCommand("General", false, "shutdown", | ||
205 | "shutdown", | ||
206 | "Quit the application", HandleQuit); | ||
207 | 194 | ||
208 | // Allow derived classes to perform initialization that | 195 | // Allow derived classes to perform initialization that |
209 | // needs to be done after the console has opened | 196 | // needs to be done after the console has opened |
210 | // | ||
211 | Initialise(); | 197 | Initialise(); |
212 | } | 198 | } |
213 | 199 | ||
@@ -218,6 +204,9 @@ namespace OpenSim.Server.Base | |||
218 | 204 | ||
219 | public virtual int Run() | 205 | public virtual int Run() |
220 | { | 206 | { |
207 | Watchdog.Enabled = true; | ||
208 | MemoryWatchdog.Enabled = true; | ||
209 | |||
221 | while (m_Running) | 210 | while (m_Running) |
222 | { | 211 | { |
223 | try | 212 | try |
@@ -235,11 +224,12 @@ namespace OpenSim.Server.Base | |||
235 | return 0; | 224 | return 0; |
236 | } | 225 | } |
237 | 226 | ||
238 | protected virtual void HandleQuit(string module, string[] args) | 227 | protected override void ShutdownSpecific() |
239 | { | 228 | { |
240 | m_Running = false; | 229 | m_Running = false; |
241 | m_log.Info("[CONSOLE] Quitting"); | 230 | m_log.Info("[CONSOLE] Quitting"); |
242 | 231 | ||
232 | base.ShutdownSpecific(); | ||
243 | } | 233 | } |
244 | 234 | ||
245 | protected virtual void ReadConfig() | 235 | protected virtual void ReadConfig() |
@@ -250,4 +240,4 @@ namespace OpenSim.Server.Base | |||
250 | { | 240 | { |
251 | } | 241 | } |
252 | } | 242 | } |
253 | } | 243 | } \ No newline at end of file |