Skip to content

Commit f6708d0

Browse files
committed
added try option
1 parent 231be03 commit f6708d0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

config.inc.php-dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
$config = array(
77
'timeout' => 2,
8+
'try' => 2,
89
'services' => array(
910
// 'www.example.tld:80',
1011
// 'pop.example.tld:110',

functions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function run(){
4848
/**
4949
* Check a service status
5050
*/
51-
function checkService($service){
51+
function checkService($service, $try = 1){
5252
list($ip, $port) = explode(':', $service);
5353
$this->config['results'][$service] = array();
5454
$this->config['results'][$service]['result'] = @fsockopen(
@@ -59,7 +59,11 @@ function checkService($service){
5959
$this->config['timeout']
6060
);
6161
if (!$this->config['results'][$service]['result']){
62-
$this->error("$service is down");
62+
$this->error("$service is down ($try/{$this->opts['try']})");
63+
if ($try < $this->opts['try']){
64+
sleep($this->opts['timeout']);
65+
return $this->checkService($service, $try + 1);
66+
}
6367
}
6468
return $this->config['results'][$service]['result'];
6569
}

0 commit comments

Comments
 (0)