Changeset 15656 for gsdl/trunk/perllib/g2futil.pm
- Timestamp:
- 2008-05-22T18:10:44+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/g2futil.pm
r15605 r15656 66 66 my $cmd = "$prog $arguments"; 67 67 68 print "*** cmd = $cmd\n";68 ### print "*** cmd = $cmd\n"; 69 69 70 70 if (open(CMD,"$cmd 2>&1 |")) … … 242 242 my ($fedora_host, $collect_dir, $options) = @_; 243 243 my $verbosity = $options->{'verbosity'}; 244 my $hostname = $options->{'hostname'}; 245 my $port = $options->{'port'}; 246 my $protocol = $options->{'protocol'}; 244 247 245 248 print STDERR "Ensuring that a correct gsdl.xml file exists on the Fedora server end\n"; … … 247 250 248 251 # 1. Find out which folder to write to: fedora_host or localhost 249 # whichever contains fedora.xml is the one we want - if none, exit with error value252 # whichever contains fedora.xml is the one we want (if none, exit with error value?) 250 253 my $fedora_home = $ENV{'FEDORA_HOME'}; 251 254 my $base_path = &util::filename_cat($fedora_home, "tomcat", "conf", "Catalina"); … … 254 257 my $xmlFile = &util::filename_cat($host_path, "fedora.xml"); 255 258 if (!-e $xmlFile) { 256 # try seeing iffolder localhost contains fedoraXML259 # check if the folder localhost contains fedoraXML 257 260 $host_path = &util::filename_cat($base_path, "localhost"); 258 261 $xmlFile = &util::filename_cat($host_path, "fedora.xml"); … … 265 268 # 2. Construct the string we are going write to the gsdl.xml file 266 269 # a. get the parent directory of collect_dir by removinbg the word 267 # "collect" from it and any optional OS-type slash at the end. 270 # "collect" from it and any optional OS-type slash at the end. 271 # (Path slash direction does not matter here.) 268 272 my $collectParentDir = $collect_dir; 269 273 $collectParentDir =~ s/collect(\/|\\)?//; 270 271 #replace \ in path as occurs on Windows with /? 272 #$collectParentDir =~ s/\\/\//g; 273 #print STDERR "**** collect's parent dir is: $collectParentDir\n"; 274 274 275 275 # b. Use the collectParentDir to create the contents of gsdl.xml 276 276 my $gsdlXMLcontents = "<?xml version='1.0' encoding='utf-8'?>\n<Context docBase=\""; … … 330 330 331 331 332 # QUESTION: 333 # Starting up the Fedora server takes a long time. How long should we wait before 334 # import continues? g2f-import relies on an up-and-running Fedora server to purge the 335 # collection from it whereas g2f-build.pl needs a ready Fedora server in order to make 336 # it ingest the FedoraMETS. 337 # Let's try waiting 10s for the Fedora server to really be up and running after the 338 # restart so import and build can work without glitches. But how can we check if this 339 # duration is actually sufficient? 340 print STDERR "Fedora server restarted. Waiting 10 seconds to ensure the server is ready...\n"; 341 sleep 10; 342 332 # Starting up the Fedora server takes a long time. We need to wait for the server to be 333 # ready before import can continue, because g2f-import relies on an up-and-running Fedora 334 # server to purge the collection from it while g2f-build.pl needs a ready Fedora server 335 # in order to make it ingest the FedoraMETS. Sleeping is not sufficient (#sleep 10;) since 336 # the subsequent steps depend on a proper server restart. 337 # Dr Bainbridge's suggestion: test the server is ready with a call to wget. 338 339 # Wget tries to retrieve the fedora search page (protocol://host:port/fedora/search) 340 # 20 times, waiting 3 seconds between each failed attempt. If it ultimately fails, we 341 # print a message to the user. 342 # The wget --spider option makes it check that the page is merely there rather than 343 # downloading it (see http://www.gnu.org/software/wget/manual/wget.html#Download-Options) 344 # -q is for quiet, --tries for the number of retries, --waitretry is the number of seconds 345 # between each attempt. Usually wget returns the contents of the page, but in our case it 346 # will return 0 for success since we are not downloading. 347 348 print STDERR "Fedora server restarted. Waiting for it to become ready...\n"; 349 350 # print STDERR "****$protocol://$hostname:$port/fedora/search\n"; 351 my $fedoraServerReady = system("wget -q --spider --waitretry=3 --tries=20 $protocol://$hostname:$port/fedora/search"); 352 if($fedoraServerReady != 0) { 353 print STDERR "Fedora server is still not ready... ERROR: $!\n"; 354 print "Exit status = ", $status/256, "\n"; 355 die "Exiting....\n"; 356 } 357 343 358 # return some indication that things went well 344 359 return "gsdl.xml";
Note:
See TracChangeset
for help on using the changeset viewer.