aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGridServices.GridServer/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices/OpenGridServices.GridServer/Main.cs')
-rw-r--r--OpenGridServices/OpenGridServices.GridServer/Main.cs81
1 files changed, 57 insertions, 24 deletions
diff --git a/OpenGridServices/OpenGridServices.GridServer/Main.cs b/OpenGridServices/OpenGridServices.GridServer/Main.cs
index cad5fae..8baf293 100644
--- a/OpenGridServices/OpenGridServices.GridServer/Main.cs
+++ b/OpenGridServices/OpenGridServices.GridServer/Main.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Sims;
41using OpenSim.Framework.Console; 41using OpenSim.Framework.Console;
42using OpenSim.Framework.Interfaces; 42using OpenSim.Framework.Interfaces;
43using OpenSim.Servers; 43using OpenSim.Servers;
44using OpenSim.GenericConfig;
44 45
45namespace OpenGridServices.GridServer 46namespace OpenGridServices.GridServer
46{ 47{
@@ -49,15 +50,17 @@ namespace OpenGridServices.GridServer
49 public class OpenGrid_Main : BaseServer, conscmd_callback 50 public class OpenGrid_Main : BaseServer, conscmd_callback
50 { 51 {
51 private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; 52 private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll";
52 private string GridDll = "OpenGrid.Framework.Data.MySQL.dll"; 53 private string GridDll = "OpenGrid.Framework.Data.DB4o.dll";
53 public GridConfig Cfg; 54 public GridConfig Cfg;
54 55
55 public static OpenGrid_Main thegrid; 56 public static OpenGrid_Main thegrid;
56 public static bool setuponly; 57 protected IGenericConfig localXMLConfig;
57 58
59 public static bool setuponly;
60
58 //public LLUUID highestUUID; 61 //public LLUUID highestUUID;
59 62
60// private SimProfileManager m_simProfileManager; 63 // private SimProfileManager m_simProfileManager;
61 64
62 private GridManager m_gridManager; 65 private GridManager m_gridManager;
63 66
@@ -70,7 +73,7 @@ namespace OpenGridServices.GridServer
70 { 73 {
71 if (args[0] == "-setuponly") setuponly = true; 74 if (args[0] == "-setuponly") setuponly = true;
72 } 75 }
73 Console.WriteLine("Starting...\n"); 76 Console.WriteLine("Starting...\n");
74 77
75 thegrid = new OpenGrid_Main(); 78 thegrid = new OpenGrid_Main();
76 thegrid.Startup(); 79 thegrid.Startup();
@@ -82,8 +85,8 @@ namespace OpenGridServices.GridServer
82 { 85 {
83 while (true) 86 while (true)
84 { 87 {
85 Thread.Sleep(5000); 88 Thread.Sleep(5000);
86 // should flush the DB etc here 89 // should flush the DB etc here
87 } 90 }
88 } 91 }
89 92
@@ -95,30 +98,37 @@ namespace OpenGridServices.GridServer
95 98
96 } 99 }
97 100
98 public void managercallback(string cmd) { 101 public void managercallback(string cmd)
99 switch(cmd) { 102 {
100 case "shutdown": 103 switch (cmd)
101 RunCmd("shutdown",new string[0]); 104 {
102 break; 105 case "shutdown":
103 } 106 RunCmd("shutdown", new string[0]);
104 } 107 break;
108 }
109 }
105 110
106 111
107 public void Startup() 112 public void Startup()
108 { 113 {
109 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration"); 114 this.localXMLConfig = new XmlConfig("GridServerConfig.xml");
115 this.localXMLConfig.LoadData();
116 this.ConfigDB(this.localXMLConfig);
117 this.localXMLConfig.Close();
118
119 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration");
110 Cfg = this.LoadConfigDll(this.ConfigDll); 120 Cfg = this.LoadConfigDll(this.ConfigDll);
111 Cfg.InitConfig(); 121 Cfg.InitConfig();
112 if(setuponly) Environment.Exit(0); 122 if (setuponly) Environment.Exit(0);
113 123
114 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Connecting to Storage Server"); 124 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Connecting to Storage Server");
115 m_gridManager = new GridManager(); 125 m_gridManager = new GridManager();
116 m_gridManager.AddPlugin(GridDll); // Made of win 126 m_gridManager.AddPlugin(GridDll); // Made of win
117 m_gridManager.config = Cfg; 127 m_gridManager.config = Cfg;
118 128
119 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting HTTP process"); 129 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP process");
120 BaseHttpServer httpServer = new BaseHttpServer(8001); 130 BaseHttpServer httpServer = new BaseHttpServer(8001);
121 GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer,"gridserver",Cfg.SimSendKey,Cfg.SimRecvKey,managercallback); 131 GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback);
122 132
123 httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcLoginToSimulatorMethod); 133 httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcLoginToSimulatorMethod);
124 httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod); 134 httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
@@ -127,7 +137,7 @@ namespace OpenGridServices.GridServer
127 httpServer.AddRestHandler("POST", "/sims/", m_gridManager.RestSetSimMethod); 137 httpServer.AddRestHandler("POST", "/sims/", m_gridManager.RestSetSimMethod);
128 httpServer.AddRestHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod); 138 httpServer.AddRestHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod);
129 httpServer.AddRestHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod); 139 httpServer.AddRestHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod);
130 140
131 141
132 // lbsa71 : This code snippet taken from old http server. 142 // lbsa71 : This code snippet taken from old http server.
133 // I have no idea what this was supposed to do - looks like an infinite recursion to me. 143 // I have no idea what this was supposed to do - looks like an infinite recursion to me.
@@ -145,9 +155,9 @@ namespace OpenGridServices.GridServer
145 155
146 httpServer.Start(); 156 httpServer.Start();
147 157
148 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting sim status checker"); 158 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting sim status checker");
149 159
150 System.Timers.Timer simCheckTimer = new System.Timers.Timer( 300000 ); // 5 minutes 160 System.Timers.Timer simCheckTimer = new System.Timers.Timer(300000); // 5 minutes
151 simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); 161 simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
152 simCheckTimer.Enabled = true; 162 simCheckTimer.Enabled = true;
153 } 163 }
@@ -222,7 +232,7 @@ namespace OpenGridServices.GridServer
222 switch (cmd) 232 switch (cmd)
223 { 233 {
224 case "help": 234 case "help":
225 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"shutdown - shutdown the grid (USE CAUTION!)"); 235 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - shutdown the grid (USE CAUTION!)");
226 break; 236 break;
227 237
228 case "shutdown": 238 case "shutdown":
@@ -235,5 +245,28 @@ namespace OpenGridServices.GridServer
235 public void Show(string ShowWhat) 245 public void Show(string ShowWhat)
236 { 246 {
237 } 247 }
248
249 private void ConfigDB(IGenericConfig configData)
250 {
251 try
252 {
253 string attri = "";
254 attri = configData.GetAttribute("DataBaseProvider");
255 if (attri == "")
256 {
257 GridDll = "OpenGrid.Framework.Data.DB4o.dll";
258 configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll");
259 }
260 else
261 {
262 GridDll = attri;
263 }
264 configData.Commit();
265 }
266 catch (Exception e)
267 {
268
269 }
270 }
238 } 271 }
239} 272}