diff options
author | gareth | 2007-05-14 00:08:52 +0000 |
---|---|---|
committer | gareth | 2007-05-14 00:08:52 +0000 |
commit | 67e7d126f3d51d593e16e18f083a03e202952bb7 (patch) | |
tree | f1c0f753adfab21102bc76151f67d605972fac78 /ServiceManager/ServiceManager.cs | |
parent | Added skeleton master service manager (diff) | |
download | opensim-SC_OLD-67e7d126f3d51d593e16e18f083a03e202952bb7.zip opensim-SC_OLD-67e7d126f3d51d593e16e18f083a03e202952bb7.tar.gz opensim-SC_OLD-67e7d126f3d51d593e16e18f083a03e202952bb7.tar.bz2 opensim-SC_OLD-67e7d126f3d51d593e16e18f083a03e202952bb7.tar.xz |
A configuration file you say?
If you say so....
Diffstat (limited to 'ServiceManager/ServiceManager.cs')
-rw-r--r-- | ServiceManager/ServiceManager.cs | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/ServiceManager/ServiceManager.cs b/ServiceManager/ServiceManager.cs index 6a613bb..cd15722 100644 --- a/ServiceManager/ServiceManager.cs +++ b/ServiceManager/ServiceManager.cs | |||
@@ -1,6 +1,8 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Threading; | 2 | using System.Threading; |
3 | using System.ServiceProcess; | 3 | using System.ServiceProcess; |
4 | using System.Xml; | ||
5 | using System.IO; | ||
4 | 6 | ||
5 | public class OpenGridMasterService : System.ServiceProcess.ServiceBase { | 7 | public class OpenGridMasterService : System.ServiceProcess.ServiceBase { |
6 | 8 | ||
@@ -21,11 +23,48 @@ public class OpenGridMasterService : System.ServiceProcess.ServiceBase { | |||
21 | 23 | ||
22 | protected override void OnStart(string[] args) | 24 | protected override void OnStart(string[] args) |
23 | { | 25 | { |
24 | 26 | ServiceWorkerThread = new Thread(new ThreadStart(MainServiceThread)); | |
25 | 27 | ServiceWorkerThread.Start(); | |
28 | } | ||
29 | |||
30 | protected override void OnStop() | ||
31 | { | ||
32 | ServiceWorkerThread.Abort(); | ||
33 | } | ||
34 | |||
35 | private void MainServiceThread() | ||
36 | { | ||
37 | try { | ||
38 | StreamReader reader=new StreamReader("opengrid-master-cfg.xml"); | ||
39 | |||
40 | string configxml = reader.ReadToEnd(); | ||
41 | XmlDocument doc = new XmlDocument(); | ||
42 | doc.LoadXml(configxml); | ||
43 | XmlNode rootnode = doc.FirstChild; | ||
44 | if (rootnode.Name != "regions") | ||
45 | { | ||
46 | EventLog.WriteEntry("ERROR! bad XML in opengrid-master-cfg.xml - expected regions tag"); | ||
47 | Console.WriteLine("Sorry, could not startup the service - please check your opengrid-master-cfg.xml file: missing regions tag"); | ||
48 | (new ServiceController("OpenGridServices-master")).Stop(); | ||
49 | } | ||
50 | |||
51 | for(int i=0; i<=rootnode.ChildNodes.Count; i++) | ||
52 | { | ||
53 | if(rootnode.ChildNodes.Item(i).Name != "region") { | ||
54 | EventLog.WriteEntry("nonfatal error - unexpected tag inside regions block of opengrid-master-cfg.xml"); | ||
55 | (new ServiceController("OpenGridServices-master")).Stop(); | ||
56 | } | ||
57 | } | ||
58 | } catch(Exception e) { | ||
59 | Console.WriteLine(e.ToString()); | ||
60 | (new ServiceController("OpenGridServices-master")).Stop(); | ||
61 | } | ||
62 | |||
26 | } | 63 | } |
27 | 64 | ||
28 | public static void Main() | 65 | public static void Main() |
29 | { | 66 | { |
67 | Console.WriteLine("Starting up OGS master service"); | ||
68 | ServiceBase.Run(new OpenGridMasterService()); | ||
30 | } | 69 | } |
31 | } | 70 | } |