File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 55
66$config = array(
77 'timeout' => 2,
8+ 'try' => 2,
89 'services' => array(
910 // 'www.example.tld:80',
1011 // 'pop.example.tld:110',
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments