diff options
Diffstat (limited to 'OpenGridServices/ServiceManager/ServiceManager.cs')
-rw-r--r-- | OpenGridServices/ServiceManager/ServiceManager.cs | 160 |
1 files changed, 0 insertions, 160 deletions
diff --git a/OpenGridServices/ServiceManager/ServiceManager.cs b/OpenGridServices/ServiceManager/ServiceManager.cs deleted file mode 100644 index b21a5b1..0000000 --- a/OpenGridServices/ServiceManager/ServiceManager.cs +++ /dev/null | |||
@@ -1,160 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Diagnostics; | ||
3 | using System.Threading; | ||
4 | using System.ServiceProcess; | ||
5 | using System.Xml; | ||
6 | using System.IO; | ||
7 | |||
8 | public class OpenGridMasterService : System.ServiceProcess.ServiceBase { | ||
9 | |||
10 | private Thread ServiceWorkerThread; | ||
11 | |||
12 | public OpenGridMasterService() | ||
13 | { | ||
14 | CanPauseAndContinue = false; | ||
15 | ServiceName = "OpenGridServices-master"; | ||
16 | } | ||
17 | |||
18 | private void InitializeComponent() | ||
19 | { | ||
20 | this.CanPauseAndContinue = false; | ||
21 | this.CanShutdown = true; | ||
22 | this.ServiceName = "OpenGridServices-master"; | ||
23 | } | ||
24 | |||
25 | protected override void OnStart(string[] args) | ||
26 | { | ||
27 | ServiceWorkerThread = new Thread(new ThreadStart(MainServiceThread)); | ||
28 | ServiceWorkerThread.Start(); | ||
29 | } | ||
30 | |||
31 | protected override void OnStop() | ||
32 | { | ||
33 | ServiceWorkerThread.Abort(); | ||
34 | } | ||
35 | |||
36 | private void MainServiceThread() | ||
37 | { | ||
38 | try { | ||
39 | StreamReader reader=new StreamReader("opengrid-master-cfg.xml"); | ||
40 | |||
41 | string configxml = reader.ReadToEnd(); | ||
42 | XmlDocument doc = new XmlDocument(); | ||
43 | doc.LoadXml(configxml); | ||
44 | XmlNode rootnode = doc.FirstChild; | ||
45 | if (rootnode.Name != "regions") | ||
46 | { | ||
47 | EventLog.WriteEntry("ERROR! bad XML in opengrid-master-cfg.xml - expected regions tag"); | ||
48 | Console.WriteLine("Sorry, could not startup the service - please check your opengrid-master-cfg.xml file: missing regions tag"); | ||
49 | (new ServiceController("OpenGridServices-master")).Stop(); | ||
50 | } | ||
51 | |||
52 | for(int i=0; i<=rootnode.ChildNodes.Count; i++) | ||
53 | { | ||
54 | if(rootnode.ChildNodes.Item(i).Name != "region") { | ||
55 | EventLog.WriteEntry("nonfatal error - unexpected tag inside regions block of opengrid-master-cfg.xml"); | ||
56 | (new ServiceController("OpenGridServices-master")).Stop(); | ||
57 | } | ||
58 | } | ||
59 | } catch(Exception e) { | ||
60 | Console.WriteLine(e.ToString()); | ||
61 | (new ServiceController("OpenGridServices-master")).Stop(); | ||
62 | } | ||
63 | |||
64 | } | ||
65 | |||
66 | private static string SetupGrid() | ||
67 | { | ||
68 | Console.WriteLine("Running external program (OpenGridServices.GridServer.exe) to configure the grid server"); | ||
69 | Process p = new Process(); | ||
70 | |||
71 | p.StartInfo.Arguments = "-setuponly"; | ||
72 | p.StartInfo.FileName = "OpenGridServices.GridServer.exe"; | ||
73 | p.Start(); | ||
74 | |||
75 | return "<gridserver />"; // we let the gridserver handle it's own setup | ||
76 | } | ||
77 | |||
78 | private static string SetupUser() | ||
79 | { | ||
80 | return "<user></user>"; | ||
81 | } | ||
82 | |||
83 | private static string SetupAsset() | ||
84 | { | ||
85 | return "<asset></asset>"; | ||
86 | } | ||
87 | |||
88 | private static string SetupRegion() | ||
89 | { | ||
90 | return "<regions></regions>"; | ||
91 | } | ||
92 | |||
93 | public static void InitSetup() | ||
94 | { | ||
95 | string choice=""; | ||
96 | |||
97 | string GridInfo; | ||
98 | string UserInfo; | ||
99 | string AssetInfo; | ||
100 | string RegionInfo; | ||
101 | |||
102 | bool grid=false; | ||
103 | bool user=false; | ||
104 | bool asset=false; | ||
105 | bool region=false; | ||
106 | while(choice!="OK") | ||
107 | { | ||
108 | Console.Clear(); | ||
109 | Console.WriteLine("Please select the components you would like to run on this server:\n"); | ||
110 | |||
111 | Console.WriteLine("1 - [" + (grid ? "X" : " ") + "] Grid server - this service handles co-ordinates of regions/sims on the grid"); | ||
112 | Console.WriteLine("2 - [" + (user ? "X" : " ") + "] User server - this service handles user login, profiles, inventory and IM"); | ||
113 | Console.WriteLine("3 - [" + (asset ? "X" : " ") + "] Asset server - this service handles storage of assets such as textures, objects, sounds, scripts"); | ||
114 | 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"); | ||
115 | |||
116 | |||
117 | Console.Write("Type a number to toggle a choice or type OK to accept your current choices: "); | ||
118 | choice = Console.ReadLine(); | ||
119 | switch(choice) | ||
120 | { | ||
121 | case "1": | ||
122 | grid = (!grid); | ||
123 | break; | ||
124 | |||
125 | case "2": | ||
126 | user = (!user); | ||
127 | break; | ||
128 | |||
129 | case "3": | ||
130 | asset = (!asset); | ||
131 | break; | ||
132 | |||
133 | case "4": | ||
134 | region = (!region); | ||
135 | break; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | if(grid) GridInfo = SetupGrid(); | ||
140 | if(user) UserInfo = SetupUser(); | ||
141 | if(asset) AssetInfo = SetupAsset(); | ||
142 | if(region) RegionInfo = SetupRegion(); | ||
143 | } | ||
144 | |||
145 | public static void Main() | ||
146 | { | ||
147 | if(!File.Exists("opengrid-master-cfg.xml")) | ||
148 | { | ||
149 | Console.WriteLine("Could not find a config file, running initial setup"); | ||
150 | InitSetup(); | ||
151 | } | ||
152 | Console.WriteLine("Starting up OGS master service"); | ||
153 | try { | ||
154 | ServiceBase.Run(new OpenGridMasterService()); | ||
155 | } catch(Exception e) { | ||
156 | Console.WriteLine("THIS SHOULD NEVER HAPPEN!!!!!!!!!!!!!!!!!!!!!"); | ||
157 | Console.WriteLine(e.ToString()); | ||
158 | } | ||
159 | } | ||
160 | } | ||