From 70fc266c42f1634dac2d6fe2dc29e8060d24ab96 Mon Sep 17 00:00:00 2001 From: paulr Date: Mon, 28 Jun 2010 00:26:26 +1000 Subject: [PATCH] trying to figure out how i would tell if a service is running from the watchdog... --- lib/systemServer.php | 10 ++++++++++ lib/watchDog.php | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/systemServer.php b/lib/systemServer.php index 8535ab6..082b8d5 100644 --- a/lib/systemServer.php +++ b/lib/systemServer.php @@ -8,8 +8,18 @@ class systemServer { function isRunning() { + if(!runningCheck) { + // this code does the check to see if it should be running .. i.e. am i the system server. we only want to do this check once + runningCheck = true; + shouldIRun = false; + } + // the purpose of this function is two fold, first determines if it should be running and return true if not // then checks if the ss is running or not and returns true if it is + return true; } + + private runningCheck = false; + private shouldIRun = false; } ?> \ No newline at end of file diff --git a/lib/watchDog.php b/lib/watchDog.php index a488950..2ea8dd7 100644 --- a/lib/watchDog.php +++ b/lib/watchDog.php @@ -4,9 +4,9 @@ class watchDog { function go() { // my job is to keep daemons running. + $lhms = new hostManagementServer(); + $lss = new systemServer(); while(true) { - $lhms = new hostManagementServer(); - $lss = new systemServer(); if(!$lhms->isRunning()) { startHMS(); @@ -15,6 +15,8 @@ class watchDog { if(!$lss->isRunning()) { startSS(); } + + sleep(5); } } -- 1.7.0.4