diff options
Diffstat (limited to 'OpenGridServices/ServiceManager')
-rw-r--r-- | OpenGridServices/ServiceManager/ServiceManager.cs | 259 | ||||
-rw-r--r-- | OpenGridServices/ServiceManager/ServiceManager.csproj | 107 | ||||
-rw-r--r-- | OpenGridServices/ServiceManager/ServiceManager.exe.build | 44 |
3 files changed, 0 insertions, 410 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 | */ | ||
28 | using System; | ||
29 | using System.Diagnostics; | ||
30 | using System.Threading; | ||
31 | using System.ServiceProcess; | ||
32 | using System.Xml; | ||
33 | using System.IO; | ||
34 | using libsecondlife; | ||
35 | using OpenSim.GenericConfig; | ||
36 | |||
37 | public 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 | } | ||
diff --git a/OpenGridServices/ServiceManager/ServiceManager.csproj b/OpenGridServices/ServiceManager/ServiceManager.csproj deleted file mode 100644 index e07e5be..0000000 --- a/OpenGridServices/ServiceManager/ServiceManager.csproj +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{E141F4EE-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon> | ||
10 | </ApplicationIcon> | ||
11 | <AssemblyKeyContainerName> | ||
12 | </AssemblyKeyContainerName> | ||
13 | <AssemblyName>ServiceManager</AssemblyName> | ||
14 | <DefaultClientScript>JScript</DefaultClientScript> | ||
15 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
16 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
17 | <DelaySign>false</DelaySign> | ||
18 | <OutputType>Exe</OutputType> | ||
19 | <AppDesignerFolder> | ||
20 | </AppDesignerFolder> | ||
21 | <RootNamespace>ServiceManager</RootNamespace> | ||
22 | <StartupObject> | ||
23 | </StartupObject> | ||
24 | <FileUpgradeFlags> | ||
25 | </FileUpgradeFlags> | ||
26 | </PropertyGroup> | ||
27 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
28 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
29 | <BaseAddress>285212672</BaseAddress> | ||
30 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
31 | <ConfigurationOverrideFile> | ||
32 | </ConfigurationOverrideFile> | ||
33 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
34 | <DocumentationFile> | ||
35 | </DocumentationFile> | ||
36 | <DebugSymbols>True</DebugSymbols> | ||
37 | <FileAlignment>4096</FileAlignment> | ||
38 | <Optimize>False</Optimize> | ||
39 | <OutputPath>..\..\bin\</OutputPath> | ||
40 | <RegisterForComInterop>False</RegisterForComInterop> | ||
41 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
42 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
43 | <WarningLevel>4</WarningLevel> | ||
44 | <NoWarn> | ||
45 | </NoWarn> | ||
46 | </PropertyGroup> | ||
47 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
48 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
49 | <BaseAddress>285212672</BaseAddress> | ||
50 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
51 | <ConfigurationOverrideFile> | ||
52 | </ConfigurationOverrideFile> | ||
53 | <DefineConstants>TRACE</DefineConstants> | ||
54 | <DocumentationFile> | ||
55 | </DocumentationFile> | ||
56 | <DebugSymbols>False</DebugSymbols> | ||
57 | <FileAlignment>4096</FileAlignment> | ||
58 | <Optimize>True</Optimize> | ||
59 | <OutputPath>..\..\bin\</OutputPath> | ||
60 | <RegisterForComInterop>False</RegisterForComInterop> | ||
61 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
62 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
63 | <WarningLevel>4</WarningLevel> | ||
64 | <NoWarn> | ||
65 | </NoWarn> | ||
66 | </PropertyGroup> | ||
67 | <ItemGroup> | ||
68 | <Reference Include="libsecondlife.dll"> | ||
69 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
70 | <Private>False</Private> | ||
71 | </Reference> | ||
72 | <Reference Include="OpenSim.Framework.dll"> | ||
73 | <HintPath>..\..\bin\OpenSim.Framework.dll</HintPath> | ||
74 | <Private>False</Private> | ||
75 | </Reference> | ||
76 | <Reference Include="OpenSim.GenericConfig.Xml"> | ||
77 | <HintPath>OpenSim.GenericConfig.Xml.dll</HintPath> | ||
78 | <Private>False</Private> | ||
79 | </Reference> | ||
80 | <Reference Include="System"> | ||
81 | <HintPath>System.dll</HintPath> | ||
82 | <Private>False</Private> | ||
83 | </Reference> | ||
84 | <Reference Include="System.ServiceProcess"> | ||
85 | <HintPath>System.ServiceProcess.dll</HintPath> | ||
86 | <Private>False</Private> | ||
87 | </Reference> | ||
88 | <Reference Include="System.Xml"> | ||
89 | <HintPath>System.Xml.dll</HintPath> | ||
90 | <Private>False</Private> | ||
91 | </Reference> | ||
92 | </ItemGroup> | ||
93 | <ItemGroup> | ||
94 | </ItemGroup> | ||
95 | <ItemGroup> | ||
96 | <Compile Include="ServiceManager.cs"> | ||
97 | <SubType>Component</SubType> | ||
98 | </Compile> | ||
99 | </ItemGroup> | ||
100 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
101 | <PropertyGroup> | ||
102 | <PreBuildEvent> | ||
103 | </PreBuildEvent> | ||
104 | <PostBuildEvent> | ||
105 | </PostBuildEvent> | ||
106 | </PropertyGroup> | ||
107 | </Project> \ No newline at end of file | ||
diff --git a/OpenGridServices/ServiceManager/ServiceManager.exe.build b/OpenGridServices/ServiceManager/ServiceManager.exe.build deleted file mode 100644 index e0502c6..0000000 --- a/OpenGridServices/ServiceManager/ServiceManager.exe.build +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="ServiceManager" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe"> | ||
11 | <resources prefix="ServiceManager" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="ServiceManager.cs" /> | ||
15 | </sources> | ||
16 | <references basedir="${project::get-base-directory()}"> | ||
17 | <lib> | ||
18 | <include name="${project::get-base-directory()}" /> | ||
19 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
20 | </lib> | ||
21 | <include name="../../bin/libsecondlife.dll" /> | ||
22 | <include name="../../bin/OpenSim.Framework.dll" /> | ||
23 | <include name="../../bin/OpenSim.GenericConfig.Xml.dll" /> | ||
24 | <include name="System.dll" /> | ||
25 | <include name="System.ServiceProcess.dll" /> | ||
26 | <include name="System.Xml.dll" /> | ||
27 | </references> | ||
28 | </csc> | ||
29 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
30 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
31 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
32 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
33 | <include name="*.dll"/> | ||
34 | <include name="*.exe"/> | ||
35 | </fileset> | ||
36 | </copy> | ||
37 | </target> | ||
38 | <target name="clean"> | ||
39 | <delete dir="${bin.dir}" failonerror="false" /> | ||
40 | <delete dir="${obj.dir}" failonerror="false" /> | ||
41 | </target> | ||
42 | <target name="doc" description="Creates documentation."> | ||
43 | </target> | ||
44 | </project> | ||