Skip to content

Commit

Permalink
Add try/catch for some RPC calls
Browse files Browse the repository at this point in the history
  • Loading branch information
khalahan committed Feb 7, 2014
1 parent b710f9e commit cca8747
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions namescan.php
Expand Up @@ -17,7 +17,12 @@

//
$rpc = new jsonRPCClient($jsonConnect);
$getinfo = $rpc->getinfo();
try {
$getinfo = $rpc->getinfo();
} catch (Exception $e) {
sleep(10);
$getinfo = $rpc->getinfo();
}
if(!$getinfo_old = get_cache('getinfo')) {
$getinfo_old = array('blocks' => 0);
}
Expand Down Expand Up @@ -128,16 +133,18 @@

// write stats
if($statDir) {
$res = $rpc->name_filter("", 0, 0, 0, "stat");
file_put_contents2($statDir.'name_count.txt', $res['count']);
echo 'NB names : '.$res['count']."\n";

$res = $rpc->name_filter("^d/", 0, 0, 0, "stat");
file_put_contents2($statDir.'domain_count.txt', $res['count']);
echo 'NB domains : '.$res['count']."\n";

file_put_contents2($statDir.'domain_bind_count.txt', count($bind_tree));
echo 'NB bind zones : '.count($bind_tree)."\n";
try {
$res = $rpc->name_filter("", 0, 0, 0, "stat");
file_put_contents2($statDir.'name_count.txt', $res['count']);
echo 'NB names : '.$res['count']."\n";

$res = $rpc->name_filter("^d/", 0, 0, 0, "stat");
file_put_contents2($statDir.'domain_count.txt', $res['count']);
echo 'NB domains : '.$res['count']."\n";

file_put_contents2($statDir.'domain_bind_count.txt', count($bind_tree));
echo 'NB bind zones : '.count($bind_tree)."\n";
} catch(Exception $e) {}
}
showDebug(6);

Expand Down

0 comments on commit cca8747

Please sign in to comment.