Changeset 25581
- Timestamp:
- 2012-05-11T22:59:46+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/bin/script/activate.pl
r25579 r25581 180 180 } 181 181 182 # send a pingaction to the GS library 182 sub ping { 183 my ($library_url, $command, $gs_mode, $site) = @_; 184 185 # "Ping" ... "succeeded" expected on success. (Ping on a collection may "not succeed".) 186 my $check_responsemsg_against_regex = q/succeeded/; 187 return config($library_url, $command, $check_responsemsg_against_regex, $site); 188 } 189 190 # send a pingaction to the GS library. General server-level ping. 183 191 sub ping_library { 184 192 my ($library_url, $gs_mode, $site) = @_; 185 193 186 if($gs_mode eq "gs2") { 187 my $command = "?a=ping"; 188 # "Ping" ... "succeeded" expected on success. (Ping on a collection may "not succeed".) 189 my $check_responsemsg_against_regex = q/succeeded/; 190 return config($library_url, $command, $check_responsemsg_against_regex); 191 } 192 elsif ($gs_mode eq "gs3") { 193 my $command = "?a=s&sa=ping"; 194 my $check_responsemsg_against_regex = "Ping succeeded."; # no other ping response messages even exist for GS3 195 config($library_url, $command, $check_responsemsg_against_regex, $site); 196 } 194 my $command = ""; 195 if($gs_mode eq "gs2") { 196 $command = "?a=ping"; 197 } 198 elsif ($gs_mode eq "gs3") { 199 $command = "?a=s&sa=ping"; 200 } 201 return &ping($library_url, $command, $gs_mode, $site); 202 } 203 204 205 # send a pingaction to a collection in GS library to check if it's active 206 sub ping_library_collection { 207 my ($library_url, $gs_mode, $qualified_collection, $site) = @_; 208 209 my $command = ""; 210 if($gs_mode eq "gs2") { 211 $command = "?a=ping&c=$qualified_collection"; 212 } 213 elsif ($gs_mode eq "gs3") { 214 $command = "?a=s&sa=ping&st=collection&sn=$qualified_collection"; 215 } 216 return &ping($library_url, $command, $gs_mode, $site); 197 217 } 198 218 … … 511 531 512 532 my $is_persistent_server = undef; 513 if($library_url) { # running server 514 &print_msg("Pinging $library_url\n"); 515 if($library_url && &ping_library($library_url, $gs_mode, $site)) { 516 # server is running, so release the collection if the server is persistent 533 if($library_url) { # undef if no valid server URL 534 535 &print_msg("Pinging $library_url\n"); 536 if(&ping_library($library_url, $gs_mode, $site)) { # server running 537 538 # server is running, so release the collection if 539 # the server is persistent and the collection is active 517 540 &print_msg("Checking if Greenstone server is persistent\n"); 518 $is_persistent_server = &is_persistent($library_url, $gs_mode); 519 if($is_persistent_server) { 541 $is_persistent_server = &is_persistent($library_url, $gs_mode); 542 543 &print_msg("Checking if the collection $qualified_collection is already active\n"); 544 my $collection_active = &ping_library_collection($library_url, $gs_mode, $qualified_collection, $site); 545 546 if($is_persistent_server && $collection_active) { 520 547 &print_msg("De-activating collection $qualified_collection\n"); 521 548 &deactivate_collection($library_url, $gs_mode, $qualified_collection, $site); … … 523 550 } 524 551 } 552 525 553 # 3. Do all the moving building to index stuff now 526 554 … … 564 592 } 565 593 566 567 594 # 4. Ping the library URL, and if it's a persistent server and running, activate the collection again 568 595 569 596 # Check for success: if building does not exist OR is empty 570 597 if(!&util::dir_exists($build_dir) || &util::is_dir_empty($build_dir)) { 571 if($library_url) { # undef if no server is running 598 599 if($library_url) { # undef if no valid server URL 600 572 601 &print_msg("Pinging $library_url\n"); 573 if(&ping_library($library_url, $gs_mode, $site)) { 574 # don't need to work out persistency of server more than once 602 if(&ping_library($library_url, $gs_mode, $site)) { # server running 603 604 # don't need to work out persistency of server more than once, since the libraryURL hasn't changed 575 605 if(!defined $is_persistent_server) { 576 606 &print_msg("Checking if Greenstone server is persistent\n"); 577 607 $is_persistent_server = &is_persistent($library_url, $gs_mode); 578 } 579 if($is_persistent_server) { 608 } 609 610 &print_msg("Checking if the collection $qualified_collection is not already active\n"); 611 my $collection_active = &ping_library_collection($library_url, $gs_mode, $qualified_collection, $site); 612 613 if($is_persistent_server && !$collection_active) { 580 614 &print_msg("Activating collection $qualified_collection\n"); 581 615 &activate_collection($library_url, $gs_mode, $qualified_collection, $site); … … 590 624 591 625 &main(scalar(@ARGV),@ARGV); 592 593 594 595
Note:
See TracChangeset
for help on using the changeset viewer.