Changeset 29948 for main/trunk


Ignore:
Timestamp:
2015-06-05T21:01:32+12:00 (9 years ago)
Author:
ak19
Message:

Final of two commits to fix rebuilding a collection using the online editor on Windows. Resolves the file lock problem. The changes to the java code from the previous commit work with changes in activate.pl in this commit. activate.pl is passed a flag now so that it no longer de-activates and re-activates the collection itself, but just concerns itself with moving building to index. The GS2Construct java code now de-activates the collection prior to calling activate.pl and then re-activates it afterward. In the way it was done before, activate.pl used to handle de- and re-activating the collection. But when it was launched from the server java code, the java VM would exit having left a copy of the file handles to the perl process when forking the process for activate.pl. The perl code could not move building to index since the file handles had locks (6 of them) on the index/text/collection.gdb. Changes have been made to GS2PerlConstructor too, so that it more cleanly closes all the pipes of a process, that the process itself may thereby exit cleanly. Not yet able to move this properly into its own classes since the StreamGobbler classes in GLI are not quite suited but were customised for FormatConverter. Further changes to activate.pl are for better error reporting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/activate.pl

    r29640 r29948  
    172172           
    173173            # check the page content is as expected
    174             my $response_content = $response_obj->content;     
     174            my $response_content = $response_obj->content;
     175            my $resultstr = $response_content;
     176            $resultstr =~ s@.*gs_content\"\>@@s;       
     177            $resultstr =~ s@</div>.*@@s;
     178           
    175179            if($response_content =~ m/$check_message_against_regex/) {
    176180                &print_msg(" Response as expected.\n", 3);
     181                &print_msg("@@@@@@ Got result:\n$resultstr\n", 4);
    177182                return 1;
    178183            } else {
     
    185190                &print_msg("\n\tBUT: command $library_url$command response UNEXPECTED.\n", 3);
    186191                &print_msg("*** Got message:\n$response_content.\n", 4);
     192                &print_msg("*** Got result:\n$resultstr\n", 3);
    187193                }
    188194                return 0; # ping on a collection may "not succeed."
     
    246252    my $check_responsemsg_against_regex = q/(succeeded)/;
    247253    my $expected_error_code = 500;
     254   
     255    &print_msg("*** COMMAND WAS: |$command|***\n", 4);
     256   
    248257    return config($library_url, $command, $check_responsemsg_against_regex, $site, $expected_error_code, $silent);
    249258}
     
    469478
    470479        print STDERR "\n";
    471         print STDERR "Usage: $progname [-collectdir c -builddir b -indexdir i -site s -removeold -keepold -verbosity v\n";
     480        print STDERR "Usage: $progname [-collectdir c -builddir b -indexdir i -site s -skipactivation -removeold -keepold -verbosity v\n";
    472481        print STDERR "\t-library_url URL] <[colgroup/]collection>\n";
    473482        print STDERR "\n";
     
    478487    # get the collection details
    479488    my $qualified_collection = pop @argv; # qualified collection
    480        
     489   
    481490    my $collect_dir = undef; #"collect"; # can't be "collect" when only -site is provided for GS3
    482491    my $build_dir = undef;
     
    484493    my $site = undef;
    485494   
     495    # if run from server (java code), it will handle deactivation and activation to prevent open file handles when java launches this script and exits:
     496    my $skipactivation = 0;
    486497    my $removeold = 0;
    487498    my $keepold = 0;
     
    503514        elsif ($arg eq "-site") {
    504515            $site = shift @argv;
     516        }
     517        elsif ($arg eq "-skipactivation") {
     518            $skipactivation = 1;
    505519        }
    506520        elsif ($arg eq "-removeold") {
     
    601615   
    602616    my $is_persistent_server = undef;
    603     if($library_url) { # undef if no valid server URL
    604    
     617    if(!$skipactivation && $library_url) { # undef if no valid server URL
     618
    605619        &print_msg("Pinging $library_url\n");       
    606620        if (&ping_library($library_url, $gs_mode, $site)) { # server running
     
    758772    if(!&FileUtils::directoryExists($build_dir) || &FileUtils::isDirectoryEmpty($build_dir)) {
    759773   
    760         if($library_url) { # undef if no valid server URL
     774        if(!$skipactivation && $library_url) { # undef if no valid server URL
    761775       
    762776            &print_msg("Pinging $library_url\n");
Note: See TracChangeset for help on using the changeset viewer.