added some code for actually starting some stuff!
[xmppcentral.git] / lib / watchDog.php
diff --git a/lib/watchDog.php b/lib/watchDog.php
new file mode 100644 (file)
index 0000000..a488950
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+
+class watchDog {
+       function go()
+       {
+               // my job is to keep daemons running.
+               while(true) {
+                       $lhms = new hostManagementServer();
+                       $lss = new systemServer();
+                       
+                       if(!$lhms->isRunning()) {
+                               startHMS();
+                       }
+                       
+                       if(!$lss->isRunning()) {
+                               startSS();
+                       }
+               }               
+       }
+       
+       function startHMS()
+       {
+               $pf = pcntl_fork();
+               if($pf == -1) {
+                       echo "Failed to fork\n";
+               } else if($pf) {
+                       // parent
+               } else {
+                       // child
+                       $hms = new hostManagementServer();
+                       $hms->go();
+               }       
+       }
+       
+       function startSS()
+       {
+               $pf2 = pcntl_fork();
+               if($pf2 == -1) {
+                       echo "Failed to fork\n";
+               } else if($pf2) {
+                       // parent
+               } else {
+                       // child
+                       $ss = new systemServer();
+                       $ss->go();
+               }               
+       }
+}
+
+?>
\ No newline at end of file