Changeset 27399

Show
Ignore:
Timestamp:
23.05.2013 13:39:24 (6 years ago)
Author:
jmt12
Message:

Try to make waiting messages a little more meaningful. Also pass a flag through to the first client to let it know it is first and the server may still be starting up

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb-edit/trunk/src/perllib/dbutil/tdbserver.pm

    r26996 r27399  
    6767  } 
    6868 
     69  my $we_started_server = 0; 
    6970  my $server_lockfile_path =  &util::filename_cat($ENV{'GSDLHOME'},'collect',$collection,'tmp','tdbserver.lock'); 
    7071  print " * Searching for TDBServer lockfile...\n"; 
     
    8182    if (!-e $server_lockfile_path) 
    8283    { 
     84      $we_started_server = 1; 
    8385      # ...start it! 
    8486      my $launch_cmd = 'TDBServer.pl "' . $$ . '" "' . $collection . '"'; 
     
    9092      my $line = ''; 
    9193      my $server_lock_file_created = 0; 
     94      autoflush STDOUT 1; 
     95      print "* Waiting for TDBServer to start"; 
    9296      my $server_host = ''; 
    9397      my $server_port = ''; 
    9498      while ($line = <SERVERIN>) 
    9599      { 
     100        print "."; 
    96101        # - watch for the line indicating a lock file has been created and 
    97102        #   populated with a sexy port number 
     
    115120      } 
    116121      close(SERVERIN); 
     122      print "\n"; 
    117123      if (!$server_lock_file_created) 
    118124      { 
     
    136142  # record this for later 
    137143  $listener_server_lockfile_paths{$server_lockfile_path} = $infodb_file_path; 
    138   return TDBClient->new($server_lockfile_path, $infodb_file); 
     144  return TDBClient->new($server_lockfile_path, $infodb_file, $we_started_server); 
    139145} 
    140146 
     
    162168  # we should now wait until all of our server_lockfiles have actually been 
    163169  # removed (otherwise people could mistakenly run import/build again 
    164   # immediately and things *might* go pearshaped). 
    165   # - actually, if they try to run again while TDB is still running, it will 
    166   #   detect an existing lockfile and immediately quit. So maybe waiting 
    167   #   isn't as important as I originally thought. I'll comment it out for now. 
    168 #  foreach my $server_lockfile_path (keys (%created_server_lockfile_paths)) 
    169 #  { 
    170 #    # While the file exists, we should wait 
    171 #    print "* Waiting for TDBServer [" . $server_lockfile_path . "] to exit..."; 
    172 #    if (-e $server_lockfile_path) 
    173 #    { 
    174 #      while (-e $server_lockfile_path) 
    175 #      { 
    176 #        print "."; 
    177 #        sleep(1); 
    178 #      } 
    179 #    } 
    180 #    print " Done!\n"; 
    181 #  } 
     170  # immediately and things *might* go pearshaped). (Subsequent testing shows it 
     171  # won't - a new Greenstone build can't start until the previous lockfile is 
     172  # removed - but I think, for ATOMic sake, I may as well make waiting a part 
     173  # of the Greenstone import/build time. 
     174  my $wait_for_exit = 1; 
     175  foreach my $server_lockfile_path (keys (%created_server_lockfile_paths)) 
     176  { 
     177    if ($wait_for_exit) 
     178    { 
     179      # While the file exists, we should wait 
     180      autoflush STDOUT 1; 
     181      print "* Waiting for TDBServer to exit [" . $server_lockfile_path . "]"; 
     182      if (-e $server_lockfile_path) 
     183      { 
     184        while (-e $server_lockfile_path) 
     185        { 
     186          print "."; 
     187          sleep(1); 
     188        } 
     189      } 
     190    } 
     191    else 
     192    { 
     193      print "* NOT Waiting for TDBServer to exit... "; 
     194    } 
     195    print " Done!\n"; 
     196  } 
    182197} 
    183198