aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs147
1 files changed, 81 insertions, 66 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
index 19f2081..bd05d59 100644
--- a/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
+++ b/OpenSim/Grid/AssetInventoryServer/AssetInventoryServer.cs
@@ -36,17 +36,19 @@ using System.Security.Cryptography.X509Certificates;
36using System.ServiceProcess; 36using System.ServiceProcess;
37using ExtensionLoader; 37using ExtensionLoader;
38using ExtensionLoader.Config; 38using ExtensionLoader.Config;
39using HttpServer; 39//using HttpServer;
40using log4net; 40using log4net;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Servers;
43using OpenSim.Framework.Console;
42 44
43namespace OpenSim.Grid.AssetInventoryServer 45namespace OpenSim.Grid.AssetInventoryServer
44{ 46{
45 public class AssetInventoryServer : ServiceBase 47 public class AssetInventoryServer : BaseOpenSimServer//ServiceBase
46 { 48 {
47 public const string CONFIG_FILE = "AssetInventoryServer.ini"; 49 public const string CONFIG_FILE = "AssetInventoryServer.ini";
48 50
49 public WebServer HttpServer; 51 //public WebServer HttpServer;
50 public IniConfigSource ConfigFile; 52 public IniConfigSource ConfigFile;
51 53
52 public IAssetStorageProvider StorageProvider; 54 public IAssetStorageProvider StorageProvider;
@@ -60,7 +62,9 @@ namespace OpenSim.Grid.AssetInventoryServer
60 62
61 public AssetInventoryServer() 63 public AssetInventoryServer()
62 { 64 {
63 this.ServiceName = "OpenSimAssetInventoryServer"; 65 m_console = new ConsoleBase("Asset");
66 MainConsole.Instance = m_console;
67 //this.ServiceName = "OpenSimAssetInventoryServer";
64 } 68 }
65 69
66 public bool Start() 70 public bool Start()
@@ -123,7 +127,7 @@ namespace OpenSim.Grid.AssetInventoryServer
123 catch (Exception ex) 127 catch (Exception ex)
124 { 128 {
125 Logger.Log.Error("Initializing the HTTP server failed, shutting down: " + ex.Message); 129 Logger.Log.Error("Initializing the HTTP server failed, shutting down: " + ex.Message);
126 Stop(); 130 Shutdown();
127 return false; 131 return false;
128 } 132 }
129 133
@@ -138,7 +142,17 @@ namespace OpenSim.Grid.AssetInventoryServer
138 return true; 142 return true;
139 } 143 }
140 144
141 public void Shutdown() 145 public void Work()
146 {
147 m_console.Notice("Enter help for a list of commands");
148
149 while (true)
150 {
151 m_console.Prompt();
152 }
153 }
154
155 public override void ShutdownSpecific()
142 { 156 {
143 foreach (IAssetInventoryServerPlugin plugin in frontends) 157 foreach (IAssetInventoryServerPlugin plugin in frontends)
144 { 158 {
@@ -162,26 +176,27 @@ namespace OpenSim.Grid.AssetInventoryServer
162 176
163 void InitHttpServer(int port, X509Certificate serverCert) 177 void InitHttpServer(int port, X509Certificate serverCert)
164 { 178 {
165 if (serverCert != null) 179 //if (serverCert != null)
166 HttpServer = new WebServer(IPAddress.Any, port, serverCert, null, false); 180 // HttpServer = new WebServer(IPAddress.Any, port, serverCert, null, false);
167 else 181 //else
168 HttpServer = new WebServer(IPAddress.Any, port); 182 // HttpServer = new WebServer(IPAddress.Any, port);
169 183
170 HttpServer.LogWriter = new log4netLogWriter(Logger.Log); 184 //HttpServer.LogWriter = new log4netLogWriter(Logger.Log);
171 185
172 HttpServer.Set404Handler( 186 //HttpServer.Set404Handler(
173 delegate(IHttpClientContext client, IHttpRequest request, IHttpResponse response) 187 // delegate(IHttpClientContext client, IHttpRequest request, IHttpResponse response)
174 { 188 // {
175 Logger.Log.Warn("Requested page was not found: " + request.Uri.PathAndQuery); 189 // Logger.Log.Warn("Requested page was not found: " + request.Uri.PathAndQuery);
176 190
177 string notFoundString = "<html><head><title>Page Not Found</title></head><body>The requested page or method was not found</body></html>"; 191 // string notFoundString = "<html><head><title>Page Not Found</title></head><body>The requested page or method was not found</body></html>";
178 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(notFoundString); 192 // byte[] buffer = System.Text.Encoding.UTF8.GetBytes(notFoundString);
179 response.Body.Write(buffer, 0, buffer.Length); 193 // response.Body.Write(buffer, 0, buffer.Length);
180 response.Status = HttpStatusCode.NotFound; 194 // response.Status = HttpStatusCode.NotFound;
181 return true; 195 // return true;
182 } 196 // }
183 ); 197 //);
184 198
199 m_httpServer = new BaseHttpServer(8003);
185 HttpServer.Start(); 200 HttpServer.Start();
186 201
187 Logger.Log.Info("Asset server is listening on port " + port); 202 Logger.Log.Info("Asset server is listening on port " + port);
@@ -189,14 +204,14 @@ namespace OpenSim.Grid.AssetInventoryServer
189 204
190 #region ServiceBase Overrides 205 #region ServiceBase Overrides
191 206
192 protected override void OnStart(string[] args) 207 //protected override void OnStart(string[] args)
193 { 208 //{
194 Start(); 209 // Start();
195 } 210 //}
196 protected override void OnStop() 211 //protected override void OnStop()
197 { 212 //{
198 Shutdown(); 213 // Shutdown();
199 } 214 //}
200 215
201 #endregion 216 #endregion
202 217
@@ -231,36 +246,36 @@ namespace OpenSim.Grid.AssetInventoryServer
231 } 246 }
232 } 247 }
233 248
234 public class log4netLogWriter : ILogWriter 249 //public class log4netLogWriter : ILogWriter
235 { 250 //{
236 ILog Log; 251 // ILog Log;
237 252
238 public log4netLogWriter(ILog log) 253 // public log4netLogWriter(ILog log)
239 { 254 // {
240 Log = log; 255 // Log = log;
241 } 256 // }
242 257
243 public void Write(object source, LogPrio prio, string message) 258 // public void Write(object source, LogPrio prio, string message)
244 { 259 // {
245 switch (prio) 260 // switch (prio)
246 { 261 // {
247 case LogPrio.Trace: 262 // case LogPrio.Trace:
248 case LogPrio.Debug: 263 // case LogPrio.Debug:
249 Log.DebugFormat("{0}: {1}", source, message); 264 // Log.DebugFormat("{0}: {1}", source, message);
250 break; 265 // break;
251 case LogPrio.Info: 266 // case LogPrio.Info:
252 Log.InfoFormat("{0}: {1}", source, message); 267 // Log.InfoFormat("{0}: {1}", source, message);
253 break; 268 // break;
254 case LogPrio.Warning: 269 // case LogPrio.Warning:
255 Log.WarnFormat("{0}: {1}", source, message); 270 // Log.WarnFormat("{0}: {1}", source, message);
256 break; 271 // break;
257 case LogPrio.Error: 272 // case LogPrio.Error:
258 Log.ErrorFormat("{0}: {1}", source, message); 273 // Log.ErrorFormat("{0}: {1}", source, message);
259 break; 274 // break;
260 case LogPrio.Fatal: 275 // case LogPrio.Fatal:
261 Log.FatalFormat("{0}: {1}", source, message); 276 // Log.FatalFormat("{0}: {1}", source, message);
262 break; 277 // break;
263 } 278 // }
264 } 279 // }
265 } 280 //}
266} 281}