/[webpac2]/trunk/run.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/run.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 768 by dpavlin, Fri Nov 3 19:41:28 2006 UTC revision 790 by dpavlin, Wed Dec 13 10:08:27 2006 UTC
# Line 8  use lib './lib'; Line 8  use lib './lib';
8    
9  use WebPAC::Common 0.02;  use WebPAC::Common 0.02;
10  use WebPAC::Parser 0.08;  use WebPAC::Parser 0.08;
11  use WebPAC::Input 0.14;  use WebPAC::Input 0.16;
12  use WebPAC::Store 0.14;  use WebPAC::Store 0.14;
13  use WebPAC::Normalize 0.22;  use WebPAC::Normalize 0.22;
14  use WebPAC::Output::TT;  use WebPAC::Output::TT;
# Line 21  use Time::HiRes qw/time/; Line 21  use Time::HiRes qw/time/;
21  use File::Slurp;  use File::Slurp;
22  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
23  use Storable qw/dclone/;  use Storable qw/dclone/;
24    use Pod::Usage qw/pod2usage/;
25    
26  use Proc::Queue size => 1;  use Proc::Queue size => 1;
27  use POSIX ":sys_wait_h"; # imports WNOHANG  use POSIX ":sys_wait_h"; # imports WNOHANG
# Line 31  run.pl - start WebPAC indexing Line 32  run.pl - start WebPAC indexing
32    
33  B<this command will probably go away. Don't get used to it!>  B<this command will probably go away. Don't get used to it!>
34    
35  Options:  =head1 OPTIONS
36    
37  =over 4  =over 4
38    
# Line 107  my $marc_dump = 0; Line 108  my $marc_dump = 0;
108  my $parallel = 0;  my $parallel = 0;
109  my $only_links = 0;  my $only_links = 0;
110  my $merge = 0;  my $merge = 0;
111    my $help;
112    
113  my $log = _new WebPAC::Common()->_get_logger();  my $log = _new WebPAC::Common()->_get_logger();
114    
# Line 125  GetOptions( Line 127  GetOptions(
127          "parallel=i" => \$parallel,          "parallel=i" => \$parallel,
128          "only-links!" => \$only_links,          "only-links!" => \$only_links,
129          "merge" => \$merge,          "merge" => \$merge,
130            "help" => \$help,
131  );  );
132    
133    pod2usage(-verbose => 2) if ($help);
134    
135  my $config = new WebPAC::Config( path => $config_path );  my $config = new WebPAC::Config( path => $config_path );
136    
137  #print "config = ",dump($config) if ($debug);  #print "config = ",dump($config) if ($debug);
# Line 135  die "no databases in config file!\n" unl Line 140  die "no databases in config file!\n" unl
140    
141  $log->info( "-" x 79 );  $log->info( "-" x 79 );
142    
143    my $log_file = 'log';
144    
145    if (-e $log_file ) {    # && -s $log_file > 5 * 1024 * 1024) {
146            $log->info("moved old log with ", -s $log_file, " bytes to '${log_file}.old'");
147            rename $log_file, "${log_file}.old" || $log->logwarn("can't rename $log_file to ${log_file}.old: $!");
148    }
149    
150  my $estcmd_fh;  my $estcmd_fh;
151  my $estcmd_path = './estcmd-merge.sh';  my $estcmd_path = './estcmd-merge.sh';
# Line 153  $validate = new WebPAC::Validate( Line 164  $validate = new WebPAC::Validate(
164    
165    
166  my $use_indexer = $config->use_indexer;  my $use_indexer = $config->use_indexer;
167    $stats ||= $validate;
168  if ($stats) {  if ($stats) {
169          $log->debug("option --stats disables update of indexing engine...");          $log->debug("disabled indexing for stats collection");
170          $use_indexer = undef;          $use_indexer = undef;
171  } else {  } else {
172          $log->info("using $use_indexer indexing engine...");          $log->info("using $use_indexer indexing engine...");
# Line 467  while (my ($database, $db_config) = each Line 479  while (my ($database, $db_config) = each
479    
480                          my $row = $input_db->fetch || next;                          my $row = $input_db->fetch || next;
481    
482                            $total_rows++;
483    
484                          my $mfn = $row->{'000'}->[0];                          my $mfn = $row->{'000'}->[0];
485    
486                          if (! $mfn || $mfn !~ m#^\d+$#) {                          if (! $mfn || $mfn !~ m#^\d+$#) {
# Line 477  while (my ($database, $db_config) = each Line 491  while (my ($database, $db_config) = each
491    
492    
493                          if ($validate) {                          if ($validate) {
494                                  if ( my $errors = $validate->validate_rec( $row, $input_db->dump ) ) {                                  if ( my $errors = $validate->validate_rec( $row, $input_db->dump_ascii ) ) {
495                                          $log->error( "MFN $mfn validation error:\n",                                          $log->error( "MFN $mfn validation error:\n",
496                                                  $validate->report_error( $errors )                                                  $validate->report_error( $errors )
497                                          );                                          );
498                                  }                                  }
499                                    next;   # validation doesn't create any output
500                          }                          }
501    
502                          my $ds = WebPAC::Normalize::data_structure(                          my $ds = WebPAC::Normalize::data_structure(
# Line 530  while (my ($database, $db_config) = each Line 545  while (my ($database, $db_config) = each
545    
546                                  $log->info("Created $i instances of MFN $mfn\n") if ($i > 1);                                  $log->info("Created $i instances of MFN $mfn\n") if ($i > 1);
547                          }                          }
   
                         $total_rows++;  
548                  }                  }
549    
550                  if ($validate) {                  if ($validate) {

Legend:
Removed from v.768  
changed lines
  Added in v.790

  ViewVC Help
Powered by ViewVC 1.1.26