From f679a231aea47e5b4aadb7f9b79d56224d130dd7 Mon Sep 17 00:00:00 2001 From: hadeshyp Date: Tue, 6 Nov 2012 21:32:57 +0000 Subject: [PATCH] Fallback when enum.js is empty or not present --- cts/htdocs/cts.pl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cts/htdocs/cts.pl b/cts/htdocs/cts.pl index c1227f4..2873d5d 100755 --- a/cts/htdocs/cts.pl +++ b/cts/htdocs/cts.pl @@ -22,18 +22,24 @@ BEGIN { sub connectToCTS { my $trb; + my $endpoint = CtsConfig->getDefaultEndpoint; + my $cache = {'enumCache' => 0}; # open cache create by monitor process to # a) reduce the number of read accesses # b) ensure the same interface is used open FH, "<" . dirname(__FILE__) . "/monitor/enum.js"; - my $json = join ' ', ; - close FH; - - my $cache = JSON_BIND->new->decode( $json ); + if (tell(FH) != -1) { + my $json = join ' ', ; + close FH; + + if ($json) { + $cache = JSON_BIND->new->decode( $json ); - $ENV{'DAQOPSERVER'} = $cache->{'daqop'}; - my $endpoint = hex $cache->{'endpoint'}; + $ENV{'DAQOPSERVER'} = $cache->{'daqop'}; + $endpoint = hex $cache->{'endpoint'}; + } + } eval {require "TrbNet.pm"}; $trb = TrbNet->new($endpoint); -- 2.43.0