/[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 607 by dpavlin, Tue Aug 1 14:15:50 2006 UTC revision 608 by dpavlin, Tue Aug 1 16:47:40 2006 UTC
# Line 93  machine if you want to use full load) Line 93  machine if you want to use full load)
93    
94  Create just links  Create just links
95    
96    =item --merge
97    
98    Create merged index of databases which have links
99    
100  =back  =back
101    
102  =cut  =cut
# Line 111  my $marc_lint = 1; Line 115  my $marc_lint = 1;
115  my $marc_dump = 0;  my $marc_dump = 0;
116  my $parallel = 0;  my $parallel = 0;
117  my $only_links = 0;  my $only_links = 0;
118    my $merge = 0;
119    
120  GetOptions(  GetOptions(
121          "limit=i" => \$limit,          "limit=i" => \$limit,
# Line 128  GetOptions( Line 133  GetOptions(
133          "marc-dump!" => \$marc_dump,          "marc-dump!" => \$marc_dump,
134          "parallel=i" => \$parallel,          "parallel=i" => \$parallel,
135          "only-links!" => \$only_links,          "only-links!" => \$only_links,
136            "merge" => \$merge,
137  );  );
138    
139  $config = LoadFile($config);  $config = LoadFile($config);
# Line 139  die "no databases in config file!\n" unl Line 145  die "no databases in config file!\n" unl
145  my $log = _new WebPAC::Common()->_get_logger();  my $log = _new WebPAC::Common()->_get_logger();
146  $log->info( "-" x 79 );  $log->info( "-" x 79 );
147    
148    
149    my $estcmd_fh;
150    my $estcmd_path = './estcmd-merge.sh';
151    if ($merge) {
152            open($estcmd_fh, '>', $estcmd_path) || $log->logdie("can't open $estcmd_path: $!");
153            print $estcmd_fh 'cd /data/estraier/_node/ || exit 1',$/;
154            print $estcmd_fh 'sudo /etc/init.d/hyperestraier stop',$/;
155            $log->info("created merge batch file $estcmd_path");
156    }
157    
158    
159  my $validate;  my $validate;
160  $validate = new WebPAC::Validate(  $validate = new WebPAC::Validate(
161          path => $validate_path,          path => $validate_path,
162  ) if ($validate_path);  ) if ($validate_path);
163    
164    
165  my $use_indexer = $config->{use_indexer} || 'hyperestraier';  my $use_indexer = $config->{use_indexer} || 'hyperestraier';
166  if ($stats) {  if ($stats) {
167          $log->debug("option --stats disables update of indexing engine...");          $log->debug("option --stats disables update of indexing engine...");
# Line 186  while (my ($database, $db_config) = each Line 204  while (my ($database, $db_config) = each
204                  $indexer_config->{clean} = $clean;                  $indexer_config->{clean} = $clean;
205                  $indexer_config->{label} = $db_config->{name};                  $indexer_config->{label} = $db_config->{name};
206    
207                    # force clean if database has links
208                    $indexer_config->{clean} = 1 if ($db_config->{links});
209    
210                  if ($use_indexer eq 'hyperestraier') {                  if ($use_indexer eq 'hyperestraier') {
211    
212                          # open Hyper Estraier database                          # open Hyper Estraier database
# Line 213  while (my ($database, $db_config) = each Line 234  while (my ($database, $db_config) = each
234          if (ref($db_config->{links}) eq 'ARRAY' && $use_indexer) {          if (ref($db_config->{links}) eq 'ARRAY' && $use_indexer) {
235                  foreach my $link (@{ $db_config->{links} }) {                  foreach my $link (@{ $db_config->{links} }) {
236                          if ($use_indexer eq 'hyperestraier') {                          if ($use_indexer eq 'hyperestraier') {
237                                  $log->info("saving link $database -> $link->{to} [$link->{credit}]");                                  if ($merge) {
238                                  push @links, sub {                                          print $estcmd_fh 'sudo -u www-data estcmd merge ' . $database . ' ' . $link->{to},$/;
239                                          $log->info("adding link $database -> $link->{to} [$link->{credit}]");                                  } else {
240                                          $indexer->add_link(                                          $log->info("saving link $database -> $link->{to} [$link->{credit}]");
241                                                  from => $database,                                          push @links, sub {
242                                                  to => $link->{to},                                                  $log->info("adding link $database -> $link->{to} [$link->{credit}]");
243                                                  credit => $link->{credit},                                                  $indexer->add_link(
244                                          );                                                          from => $database,
245                                  };                                                          to => $link->{to},
246                                                            credit => $link->{credit},
247                                                    );
248                                            };
249                                    }
250                          } else {                          } else {
251                                  $log->warn("NOT IMPLEMENTED WITH $use_indexer: adding link $database -> $link->{to} [$link->{credit}]");                                  $log->warn("NOT IMPLEMENTED WITH $use_indexer: adding link $database -> $link->{to} [$link->{credit}]");
252                          }                          }
# Line 440  if ($parallel) { Line 465  if ($parallel) {
465          $log->info("all parallel processes finished");          $log->info("all parallel processes finished");
466  }  }
467    
468    #
469  foreach my $link (@links) {  # handle links or merge after indexing
470          $log->logdie("coderef in link ", Dumper($link), " is ", ref($link), " and not CODE") unless (ref($link) eq 'CODE');  #
471          $link->();  
472    if ($merge) {
473            print $estcmd_fh 'sudo /etc/init.d/hyperestraier start',$/;
474            close($estcmd_fh);
475            chmod 0700, $estcmd_path || $log->warn("can't chmod 0700 $estcmd_path: $!");
476            system $estcmd_path;
477    } else {
478            foreach my $link (@links) {
479                    $log->logdie("coderef in link ", Dumper($link), " is ", ref($link), " and not CODE") unless (ref($link) eq 'CODE');
480                    $link->();
481            }
482  }  }
   

Legend:
Removed from v.607  
changed lines
  Added in v.608

  ViewVC Help
Powered by ViewVC 1.1.26