trying to figure out how i would tell if a service is running from the watchdog...
[xmppcentral.git] / lib / watchDog.php
1 <?php
2
3 class watchDog {
4         function go()
5         {
6                 // my job is to keep daemons running.
7                 $lhms = new hostManagementServer();
8                 $lss = new systemServer();
9                 while(true) {
10                         
11                         if(!$lhms->isRunning()) {
12                                 startHMS();
13                         }
14                         
15                         if(!$lss->isRunning()) {
16                                 startSS();
17                         }
18                         
19                         sleep(5);
20                 }               
21         }
22         
23         function startHMS()
24         {
25                 $pf = pcntl_fork();
26                 if($pf == -1) {
27                         echo "Failed to fork\n";
28                 } else if($pf) {
29                         // parent
30                 } else {
31                         // child
32                         $hms = new hostManagementServer();
33                         $hms->go();
34                 }       
35         }
36         
37         function startSS()
38         {
39                 $pf2 = pcntl_fork();
40                 if($pf2 == -1) {
41                         echo "Failed to fork\n";
42                 } else if($pf2) {
43                         // parent
44                 } else {
45                         // child
46                         $ss = new systemServer();
47                         $ss->go();
48                 }               
49         }
50 }
51
52 ?>