aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/ServiceManager/ServiceManager.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-06-09 00:42:51 +0000
committerAdam Frisby2007-06-09 00:42:51 +0000
commitba8fcfe99068bdc381bb073423fb88c3bff8d4e0 (patch)
treea9f2cf69f8458f6a5d47213cecee783466bb138f /OpenGridServices/ServiceManager/ServiceManager.cs
parent*Added delegates and events for parcel and estate management (diff)
downloadopensim-SC_OLD-ba8fcfe99068bdc381bb073423fb88c3bff8d4e0.zip
opensim-SC_OLD-ba8fcfe99068bdc381bb073423fb88c3bff8d4e0.tar.gz
opensim-SC_OLD-ba8fcfe99068bdc381bb073423fb88c3bff8d4e0.tar.bz2
opensim-SC_OLD-ba8fcfe99068bdc381bb073423fb88c3bff8d4e0.tar.xz
* Removed ServiceManager from OGS/Sugilite due to compilation issues.
* Removed GridInterface reference from AssetServer
Diffstat (limited to 'OpenGridServices/ServiceManager/ServiceManager.cs')
-rw-r--r--OpenGridServices/ServiceManager/ServiceManager.cs259
1 files changed, 0 insertions, 259 deletions
diff --git a/OpenGridServices/ServiceManager/ServiceManager.cs b/OpenGridServices/ServiceManager/ServiceManager.cs
deleted file mode 100644
index 8cb9c80..0000000
--- a/OpenGridServices/ServiceManager/ServiceManager.cs
+++ /dev/null
@@ -1,259 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Diagnostics;
30using System.Threading;
31using System.ServiceProcess;
32using System.Xml;
33using System.IO;
34using libsecondlife;
35using OpenSim.GenericConfig;
36
37public class OpenGridMasterService : System.ServiceProcess.ServiceBase {
38
39 private Thread ServiceWorkerThread;
40 private static string GridURL; // URL of grid server
41 private static string GridSimKey; // key sent from Grid>Sim
42 private static string SimGridKey; // key sent Sim>Grid
43 private static string AssetURL; // URL of asset server
44 private static string UserSendKey; // key sent from user>sim
45 private static string UserRecvKey; // key sent from sim>user
46
47 public OpenGridMasterService()
48 {
49 CanPauseAndContinue = false;
50 ServiceName = "OpenGridServices-master";
51 }
52
53 private void InitializeComponent()
54 {
55 this.CanPauseAndContinue = false;
56 this.CanShutdown = true;
57 this.ServiceName = "OpenGridServices-master";
58 }
59
60 protected override void OnStart(string[] args)
61 {
62 ServiceWorkerThread = new Thread(new ThreadStart(MainServiceThread));
63 ServiceWorkerThread.Start();
64 }
65
66 protected override void OnStop()
67 {
68 ServiceWorkerThread.Abort();
69 }
70
71 private void MainServiceThread()
72 {
73 try {
74 StreamReader reader=new StreamReader("opengrid-master-cfg.xml");
75
76 string configxml = reader.ReadToEnd();
77 XmlDocument doc = new XmlDocument();
78 doc.LoadXml(configxml);
79 XmlNode rootnode = doc.FirstChild;
80 if (rootnode.Name != "regions")
81 {
82 EventLog.WriteEntry("ERROR! bad XML in opengrid-master-cfg.xml - expected regions tag");
83 Console.WriteLine("Sorry, could not startup the service - please check your opengrid-master-cfg.xml file: missing regions tag");
84 (new ServiceController("OpenGridServices-master")).Stop();
85 }
86
87 for(int i=0; i<=rootnode.ChildNodes.Count; i++)
88 {
89 if(rootnode.ChildNodes.Item(i).Name != "region") {
90 EventLog.WriteEntry("nonfatal error - unexpected tag inside regions block of opengrid-master-cfg.xml");
91 (new ServiceController("OpenGridServices-master")).Stop();
92 }
93 }
94 } catch(Exception e) {
95 Console.WriteLine(e.ToString());
96 (new ServiceController("OpenGridServices-master")).Stop();
97 }
98
99 }
100
101 private static string SetupGrid()
102 {
103 Console.WriteLine("Running external program (OpenGridServices.GridServer.exe) to configure the grid server");
104 try {
105 Process p = new Process();
106
107 p.StartInfo.Arguments = "-setuponly";
108 p.StartInfo.FileName = "OpenGridServices.GridServer.exe";
109 p.Start();
110
111 p.StartInfo.Arguments = "-dumpxmlconf";
112 p.Start();
113
114 XmlConfig GridConf = new XmlConfig("opengrid-cfg.xml");
115 GridConf.LoadData();
116 GridURL="http://" + GridConf.GetAttribute("ListenAddr") + ":" + GridConf.GetAttribute("ListenPort") + "/";
117
118 StreamReader reader=new StreamReader("opengrid-cfg.xml");
119 string configxml = reader.ReadToEnd();
120
121 return configxml;
122 } catch(Exception e) {
123 Console.WriteLine("An error occurred while running the grid server, please rectify it and try again");
124 Console.WriteLine(e.ToString());
125 Environment.Exit(1);
126 }
127 return "";
128 }
129
130 private static string SetupUser()
131 {
132 return "<user></user>";
133 }
134
135 private static string SetupAsset()
136 {
137 return "<asset></asset>";
138 }
139
140 private static string SetupRegion()
141 {
142 string regionname;
143 ulong regionlocx;
144 ulong regionlocy;
145 string default_terrain;
146 uint terrain_multiplier;
147 uint baseport;
148
149 string listenaddr;
150 string simconfigxml;
151 LLUUID SimUUID;
152
153 Console.WriteLine("Setting up region servers");
154 Console.Write("Please specify a path to store your region data (e.g /etc/opensim/regions: ");
155 string regionpath=Console.ReadLine();
156
157 Console.Write("How many regions would you like to configure now? ");
158 int numofregions=Convert.ToInt16(Console.ReadLine());
159
160 Console.Write("What port should the region servers start listening at (first region is normally 9000, then 9001 the second etc, both TCP+UDP): ");
161 baseport=Convert.ToUInt16(Console.ReadLine());
162
163
164 listenaddr=Console.ReadLine();
165
166 Console.WriteLine("Now ready to configure regions, please answer the questions about each region in turn");
167 for(int i=0; i<=numofregions; i++) {
168 Console.WriteLine("Configuring region number " + i.ToString());
169
170 Console.Write("Region name: ");
171 regionname=Console.ReadLine();
172
173 Console.Write("Region location X: ");
174 regionlocx=(ulong)Convert.ToUInt32(Console.ReadLine());
175
176 Console.Write("Region location Y: ");
177 regionlocy=(ulong)Convert.ToUInt32(Console.ReadLine());
178
179 Console.Write("Default terrain file: ");
180 default_terrain=Console.ReadLine();
181 terrain_multiplier=Convert.ToUInt16(Console.ReadLine());
182
183 SimUUID=LLUUID.Random();
184
185 simconfigxml="<Root><Config SimUUID=\"" + SimUUID.ToString() + "\" SimName=\"" + regionname + "\" SimLocationX=\"" + regionlocx.ToString() + "\" SimLocationY=\"" + regionlocy.ToString() + "\" Datastore=\"" + Path.Combine(regionpath,(SimUUID.ToString()+"localworld.yap")) + "\" SimListenPort=\"" + (baseport+i).ToString() + "\" SimListenAddress=\"" + listenaddr + "\" TerrainFile=\"" + default_terrain + "\" TerrainMultiplier=\"" + terrain_multiplier.ToString() + "\" GridServerURL=\"\" GridSendKey=\"\" GridRecvKey=\"\" AssetServerURL=\"\" /></Root>";
186
187 }
188
189 return "<regions></regions>";
190 }
191
192 public static void InitSetup()
193 {
194 string choice="";
195
196 string GridInfo;
197 string UserInfo;
198 string AssetInfo;
199 string RegionInfo;
200
201 bool grid=false;
202 bool user=false;
203 bool asset=false;
204 bool region=false;
205 while(choice!="OK")
206 {
207 Console.Clear();
208 Console.WriteLine("Please select the components you would like to run on this server:\n");
209
210 Console.WriteLine("1 - [" + (grid ? "X" : " ") + "] Grid server - this service handles co-ordinates of regions/sims on the grid");
211 Console.WriteLine("2 - [" + (user ? "X" : " ") + "] User server - this service handles user login, profiles, inventory and IM");
212 Console.WriteLine("3 - [" + (asset ? "X" : " ") + "] Asset server - this service handles storage of assets such as textures, objects, sounds, scripts");
213 Console.WriteLine("4 - [" + (region ? "X" : " ") + "] Region server - this is the main opensim server and can run without the above services, it handles physics simulation, terrain, building and other such features");
214
215
216 Console.Write("Type a number to toggle a choice or type OK to accept your current choices: ");
217 choice = Console.ReadLine();
218 switch(choice)
219 {
220 case "1":
221 grid = (!grid);
222 break;
223
224 case "2":
225 user = (!user);
226 break;
227
228 case "3":
229 asset = (!asset);
230 break;
231
232 case "4":
233 region = (!region);
234 break;
235 }
236 }
237
238 if(grid) GridInfo = SetupGrid();
239 if(user) UserInfo = SetupUser();
240 if(asset) AssetInfo = SetupAsset();
241 if(region) RegionInfo = SetupRegion();
242 }
243
244 public static void Main()
245 {
246 if(!File.Exists("opengrid-master-cfg.xml"))
247 {
248 Console.WriteLine("Could not find a config file, running initial setup");
249 InitSetup();
250 }
251 Console.WriteLine("Starting up OGS master service");
252 try {
253 ServiceBase.Run(new OpenGridMasterService());
254 } catch(Exception e) {
255 Console.WriteLine("An error occured while initialising OGS master service.");
256 Console.WriteLine(e.ToString());
257 }
258 }
259}