/[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 512 by dpavlin, Mon May 15 18:27:15 2006 UTC revision 775 by dpavlin, Sun Nov 5 12:28:37 2006 UTC
# Line 4  use strict; Line 4  use strict;
4    
5  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
6  use File::Temp qw/tempdir/;  use File::Temp qw/tempdir/;
 use Data::Dumper;  
7  use lib './lib';  use lib './lib';
8    
9  use WebPAC::Common 0.02;  use WebPAC::Common 0.02;
10  use WebPAC::Lookup;  use WebPAC::Parser 0.08;
11  use WebPAC::Input 0.03;  use WebPAC::Input 0.16;
12  use WebPAC::Store 0.03;  use WebPAC::Store 0.14;
13  use WebPAC::Normalize::XML;  use WebPAC::Normalize 0.22;
 use WebPAC::Normalize::Set;  
14  use WebPAC::Output::TT;  use WebPAC::Output::TT;
15  use YAML qw/LoadFile/;  use WebPAC::Validate 0.06;
16    use WebPAC::Output::MARC;
17    use WebPAC::Config;
18  use Getopt::Long;  use Getopt::Long;
19  use File::Path;  use File::Path;
20  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
21  use File::Slurp;  use File::Slurp;
22    use Data::Dump qw/dump/;
23    use Storable qw/dclone/;
24    
25    use Proc::Queue size => 1;
26    use POSIX ":sys_wait_h"; # imports WNOHANG
27    
28  =head1 NAME  =head1 NAME
29    
# Line 53  or C<type> from input Line 58  or C<type> from input
58    
59  path to YAML configuration file  path to YAML configuration file
60    
61  =item --force-set  =item --stats
62    
63    disable indexing, modify_* in configuration and dump statistics about field
64    and subfield usage for each input
65    
66  force conversion C<< normalize->path >> in C<config.yml> from  =item --validate path/to/validation_file
 C<.xml> to C<.pl>  
67    
68  =item --stats  turn on extra validation of imput records, see L<WebPAC::Validation>
69    
70    =item --marc-lint
71    
72    By default turned on if normalisation file has C<marc*> directives. You can disable lint
73    messages with C<--no-marc-lint>.
74    
75    =item --marc-dump
76    
77    Force dump or input and marc record for debugging.
78    
79  disable indexing and dump statistics about field and subfield  =item --parallel 4
80  usage for each input  
81    Run databases in parallel (aproximatly same as number of processors in
82    machine if you want to use full load)
83    
84    =item --only-links
85    
86    Create just links
87    
88    =item --merge
89    
90    Create merged index of databases which have links
91    
92  =back  =back
93    
# Line 71  my $offset; Line 97  my $offset;
97  my $limit;  my $limit;
98    
99  my $clean = 0;  my $clean = 0;
100  my $config = 'conf/config.yml';  my $config_path;
101  my $debug = 0;  my $debug = 0;
102  my $only_filter;  my $only_filter;
 my $force_set = 0;  
103  my $stats = 0;  my $stats = 0;
104    my $validate_path;
105    my $marc_lint = 1;
106    my $marc_dump = 0;
107    my $parallel = 0;
108    my $only_links = 0;
109    my $merge = 0;
110    
111    my $log = _new WebPAC::Common()->_get_logger();
112    
113  GetOptions(  GetOptions(
114          "limit=i" => \$limit,          "limit=i" => \$limit,
# Line 83  GetOptions( Line 116  GetOptions(
116          "clean" => \$clean,          "clean" => \$clean,
117          "one=s" => \$only_filter,          "one=s" => \$only_filter,
118          "only=s" => \$only_filter,          "only=s" => \$only_filter,
119          "config" => \$config,          "config" => \$config_path,
120          "debug" => \$debug,          "debug+" => \$debug,
         "force-set" => \$force_set,  
121          "stats" => \$stats,          "stats" => \$stats,
122            "validate=s" => \$validate_path,
123            "marc-lint!" => \$marc_lint,
124            "marc-dump!" => \$marc_dump,
125            "parallel=i" => \$parallel,
126            "only-links!" => \$only_links,
127            "merge" => \$merge,
128  );  );
129    
130  $config = LoadFile($config);  my $config = new WebPAC::Config( path => $config_path );
131    
132  print "config = ",Dumper($config) if ($debug);  #print "config = ",dump($config) if ($debug);
133    
134  die "no databases in config file!\n" unless ($config->{databases});  die "no databases in config file!\n" unless ($config->databases);
135    
 my $log = _new WebPAC::Common()->_get_logger();  
136  $log->info( "-" x 79 );  $log->info( "-" x 79 );
137    
138  my $use_indexer = $config->{use_indexer} || 'hyperestraier';  my $log_file = 'log';
139    
140    if (-e $log_file ) {    # && -s $log_file > 5 * 1024 * 1024) {
141            $log->info("moved old log with ", -s $log_file, " bytes to '${log_file}.old'");
142            rename $log_file, "${log_file}.old" || $log->logwarn("can't rename $log_file to ${log_file}.old: $!");
143    }
144    
145    my $estcmd_fh;
146    my $estcmd_path = './estcmd-merge.sh';
147    if ($merge) {
148            open($estcmd_fh, '>', $estcmd_path) || $log->logdie("can't open $estcmd_path: $!");
149            print $estcmd_fh 'cd /data/estraier/_node/ || exit 1',$/;
150            print $estcmd_fh 'sudo /etc/init.d/hyperestraier stop',$/;
151            $log->info("created merge batch file $estcmd_path");
152    }
153    
154    
155    my $validate;
156    $validate = new WebPAC::Validate(
157            path => $validate_path,
158    ) if ($validate_path);
159    
160    
161    my $use_indexer = $config->use_indexer;
162    $stats ||= $validate;
163  if ($stats) {  if ($stats) {
164          $log->debug("option --stats disables update of indexing engine...");          $log->debug("disabled indexing for stats collection");
165          $use_indexer = undef;          $use_indexer = undef;
166  } else {  } else {
167          $log->info("using $use_indexer indexing engine...");          $log->info("using $use_indexer indexing engine...");
168  }  }
169    
170    # parse normalize files and create source files for lookup and normalization
171    
172    my $parser = new WebPAC::Parser( config => $config );
173    
174  my $total_rows = 0;  my $total_rows = 0;
175  my $start_t = time();  my $start_t = time();
176    
177  while (my ($database, $db_config) = each %{ $config->{databases} }) {  my @links;
178    
179    if ($parallel) {
180            $log->info("Using $parallel processes for speedup");
181            Proc::Queue::size($parallel);
182    }
183    
184    sub create_ds_config {
185            my ($db_config, $database, $input, $mfn) = @_;
186            my $c = dclone( $db_config );
187            $c->{_} = $database || $log->logconfess("need database");
188            $c->{_mfn} = $mfn || $log->logconfess("need mfn");
189            $c->{input} = $input || $log->logconfess("need input");
190            return $c;
191    }
192    
193    while (my ($database, $db_config) = each %{ $config->databases }) {
194    
195          my ($only_database,$only_input) = split(m#/#, $only_filter) if ($only_filter);          my ($only_database,$only_input) = split(m#/#, $only_filter) if ($only_filter);
196          next if ($only_database && $database !~ m/$only_database/i);          next if ($only_database && $database !~ m/$only_database/i);
197    
198            if ($parallel) {
199                    my $f=fork;
200                    if(defined ($f) and $f==0) {
201                            $log->info("Created processes $$ for speedup");
202                    } else {
203                            next;
204                    }
205            }
206    
207          my $indexer;          my $indexer;
208            if ($use_indexer && $parser->have_rules( 'search', $database )) {
209    
210          if ($use_indexer) {                  my $cfg_name = $use_indexer;
211                  my $indexer_config = $config->{$use_indexer} || $log->logdie("can't find '$use_indexer' part in confguration");                  $cfg_name =~ s/\-.*$//;
212    
213                    my $indexer_config = $config->get( $cfg_name ) || $log->logdie("can't find '$cfg_name' part in confguration");
214                  $indexer_config->{database} = $database;                  $indexer_config->{database} = $database;
215                  $indexer_config->{clean} = $clean;                  $indexer_config->{clean} = $clean;
216                  $indexer_config->{label} = $db_config->{name};                  $indexer_config->{label} = $db_config->{name};
217    
218                    # force clean if database has links
219                    $indexer_config->{clean} = 1 if ($db_config->{links});
220    
221                  if ($use_indexer eq 'hyperestraier') {                  if ($use_indexer eq 'hyperestraier') {
222    
223                          # open Hyper Estraier database                          # open Hyper Estraier database
224                          use WebPAC::Output::Estraier '0.10';                          use WebPAC::Output::Estraier '0.10';
225                          $indexer = new WebPAC::Output::Estraier( %{ $indexer_config } );                          $indexer = new WebPAC::Output::Estraier( %{ $indexer_config } );
226                                    
227                    } elsif ($use_indexer eq 'hyperestraier-native') {
228    
229                            # open Hyper Estraier database
230                            use WebPAC::Output::EstraierNative;
231                            $indexer = new WebPAC::Output::EstraierNative( %{ $indexer_config } );
232    
233                  } elsif ($use_indexer eq 'kinosearch') {                  } elsif ($use_indexer eq 'kinosearch') {
234    
235                          # open KinoSearch                          # open KinoSearch
# Line 144  while (my ($database, $db_config) = each Line 246  while (my ($database, $db_config) = each
246    
247    
248          #          #
249            # store Hyper Estraier links to other databases
250            #
251            if (ref($db_config->{links}) eq 'ARRAY' && $use_indexer) {
252                    foreach my $link (@{ $db_config->{links} }) {
253                            if ($use_indexer eq 'hyperestraier') {
254                                    if ($merge) {
255                                            print $estcmd_fh 'sudo -u www-data estcmd merge ' . $database . ' ' . $link->{to},$/;
256                                    } else {
257                                            $log->info("saving link $database -> $link->{to} [$link->{credit}]");
258                                            push @links, sub {
259                                                    $log->info("adding link $database -> $link->{to} [$link->{credit}]");
260                                                    $indexer->add_link(
261                                                            from => $database,
262                                                            to => $link->{to},
263                                                            credit => $link->{credit},
264                                                    );
265                                            };
266                                    }
267                            } else {
268                                    $log->warn("NOT IMPLEMENTED WITH $use_indexer: adding link $database -> $link->{to} [$link->{credit}]");
269                            }
270                    }
271            }
272            next if ($only_links);
273    
274    
275            #
276          # now WebPAC::Store          # now WebPAC::Store
277          #          #
278          my $abs_path = abs_path($0);          my $abs_path = abs_path($0);
279          $abs_path =~ s#/[^/]*$#/#;          $abs_path =~ s#/[^/]*$#/#;
280    
281          my $db_path = $config->{webpac}->{db_path} . '/' . $database;          my $db_path = $config->webpac('db_path');
282    
283          if ($clean) {          if ($clean) {
284                  $log->info("creating new database '$database' in $db_path");                  $log->info("creating new database '$database' in $db_path");
# Line 158  while (my ($database, $db_config) = each Line 287  while (my ($database, $db_config) = each
287                  $log->info("working on database '$database' in $db_path");                  $log->info("working on database '$database' in $db_path");
288          }          }
289    
290          my $db = new WebPAC::Store(          my $store = new WebPAC::Store(
291                  path => $db_path,                  path => $db_path,
                 database => $database,  
292                  debug => $debug,                  debug => $debug,
293          );          );
294    
# Line 178  while (my ($database, $db_config) = each Line 306  while (my ($database, $db_config) = each
306                  $log->info("database $database doesn't have inputs defined");                  $log->info("database $database doesn't have inputs defined");
307          }          }
308    
         my @supported_inputs = keys %{ $config->{webpac}->{inputs} };  
   
309          foreach my $input (@inputs) {          foreach my $input (@inputs) {
310    
311                  next if ($only_input && ($input->{name} !~ m#$only_input#i && $input->{type} !~ m#$only_input#i));                  my $input_name = $input->{name} || $log->logdie("input without a name isn't valid: ",dump($input));
312    
313                    next if ($only_input && ($input_name !~ m#$only_input#i && $input->{type} !~ m#$only_input#i));
314    
315                  my $type = lc($input->{type});                  my $type = lc($input->{type});
316    
317                  die "I know only how to handle input types ", join(",", @supported_inputs), " not '$type'!\n" unless (grep(/$type/, @supported_inputs));                  die "I know only how to handle input types ", join(",", $config->webpac('inputs') ), " not '$type'!\n" unless (grep(/$type/, $config->webpac('inputs')));
318    
319                  my $lookup = new WebPAC::Lookup(                  my $input_module = $config->webpac('inputs')->{$type};
                         lookup_file => $input->{lookup},  
                 );  
320    
321                  my $input_module = $config->{webpac}->{inputs}->{$type};                  my @lookups = $parser->have_lookup_create($database, $input);
322    
323                  $log->info("working on input '$input->{name}' in $input->{path} [type: $input->{type}] using $input_module lookup '$input->{lookup}'");                  $log->info("working on input '$input_name' in $input->{path} [type: $input->{type}] using $input_module",
324                            @lookups ? " creating lookups: ".join(", ", @lookups) : ""
325                    );
326    
327                    if ($stats) {
328                            # disable modification of records if --stats is in use
329                            delete($input->{modify_records});
330                            delete($input->{modify_file});
331                    }
332    
333                  my $input_db = new WebPAC::Input(                  my $input_db = new WebPAC::Input(
334                          module => $input_module,                          module => $input_module,
335                          code_page => $config->{webpac}->{webpac_encoding},                          encoding => $config->webpac('webpac_encoding'),
336                          limit => $limit || $input->{limit},                          limit => $limit || $input->{limit},
337                          offset => $offset,                          offset => $offset,
                         lookup => $lookup,  
338                          recode => $input->{recode},                          recode => $input->{recode},
339                          stats => $stats,                          stats => $stats,
340                            modify_records => $input->{modify_records},
341                            modify_file => $input->{modify_file},
342                  );                  );
343                  $log->logdie("can't create input using $input_module") unless ($input);                  $log->logdie("can't create input using $input_module") unless ($input);
344    
345                    if (defined( $input->{lookup} )) {
346                            $log->warn("$database/$input_name has depriciated lookup definition, removing it...");
347                            delete( $input->{lookup} );
348                    }
349    
350                    my $lookup_coderef;
351    
352                    if (@lookups) {
353    
354                            my $rules = $parser->lookup_create_rules($database, $input) || $log->logdie("no rules found for $database/$input");
355    
356                            $lookup_coderef = sub {
357                                    my $rec = shift || die "need rec!";
358                                    my $mfn = $rec->{'000'}->[0] || die "need mfn in 000";
359    
360                                    WebPAC::Normalize::data_structure(
361                                            row => $rec,
362                                            rules => $rules,
363                                            config => create_ds_config( $db_config, $database, $input, $mfn ),
364                                    );
365    
366                                    #warn "current lookup: ", dump(WebPAC::Normalize::_get_lookup());
367                            };
368    
369                            WebPAC::Normalize::_set_lookup( undef );
370    
371                            $log->debug("created lookup_coderef using:\n$rules");
372    
373                    };
374    
375                    my $lookup_jar;
376    
377                  my $maxmfn = $input_db->open(                  my $maxmfn = $input_db->open(
378                          path => $input->{path},                          path => $input->{path},
379                          code_page => $input->{encoding},        # database encoding                          code_page => $input->{encoding},        # database encoding
380                  );                          lookup_coderef => $lookup_coderef,
381                            lookup => $lookup_jar,
382                            %{ $input },
383                            load_row => sub {
384                                    my $a = shift;
385                                    return $store->load_row(
386                                            database => $database,
387                                            input => $input_name,
388                                            id => $a->{id},
389                                    );
390                            },
391                            save_row => sub {
392                                    my $a = shift;
393                                    return $store->save_row(
394                                            database => $database,
395                                            input => $input_name,
396                                            id => $a->{id},
397                                            row => $a->{row},
398                                    );
399                            },
400    
                 my $n = new WebPAC::Normalize::XML(  
                 #       filter => { 'foo' => sub { shift } },  
                         db => $db,  
                         lookup_regex => $lookup->regex,  
                         lookup => $lookup,  
                         prefix => $input->{name},  
401                  );                  );
402    
403                  my $rules;                  my $lookup_data = WebPAC::Normalize::_get_lookup();
                 my $normalize_path = $input->{normalize}->{path};  
404    
405                  if ($force_set) {                  if (defined( $lookup_data->{$database}->{$input_name} )) {
406                          my $new_norm_path = $normalize_path;                          $log->debug("created following lookups: ", sub { dump( $lookup_data ) } );
407                          $new_norm_path =~ s/\.xml$/.pl/;  
408                          if (-e $new_norm_path) {                          foreach my $key (keys %{ $lookup_data->{$database}->{$input_name} }) {
409                                  $log->debug("--force-set replaced $normalize_path with $new_norm_path");                                  $store->save_lookup(
410                                  $normalize_path = $new_norm_path;                                          database => $database,
411                          } else {                                          input => $input_name,
412                                  $log->debug("--force-set failed on $new_norm_path, fallback to $normalize_path");                                          key => $key,
413                                            data => $lookup_data->{$database}->{$input_name}->{$key},
414                                    );
415                          }                          }
416                  }                  }
417    
418                  if ($normalize_path =~ m/\.xml$/i) {                  my $report_fh;
419                          $n->open(                  if ($stats || $validate) {
420                                  tag => $input->{normalize}->{tag},                          my $path = "out/report/${database}-${input_name}.txt";
421                                  xml_file => $normalize_path,                          open($report_fh, '>', $path) || $log->logdie("can't open $path: $!");
422                          );  
423                  } elsif ($normalize_path =~ m/\.(?:yml|yaml)$/i) {                          print $report_fh "Report for database '$database' input '$input_name' records ",
424                          $n->open_yaml(                                  $offset || 1, "-", $limit || $input->{limit} || $maxmfn, "\n\n";
425                                  path => $normalize_path,                          $log->info("Generating report file $path");
426                                  tag => $input->{normalize}->{tag},                  }
427    
428                    my $marc;
429                    if ($parser->have_rules( 'marc', $database, $input_name )) {
430                            $marc = new WebPAC::Output::MARC(
431                                    path => "out/marc/${database}-${input_name}.marc",
432                                    lint => $marc_lint,
433                                    dump => $marc_dump,
434                          );                          );
                 } elsif ($normalize_path =~ m/\.(?:pl)$/i) {  
                         $n = undef;  
                         $log->info("using WebPAC::Normalize::Set to process $normalize_path");  
                         $rules = read_file( $normalize_path ) or die "can't open $normalize_path: $!";  
435                  }                  }
436    
437                    my $rules = $parser->normalize_rules($database,$input_name) || $log->logdie("no normalize rules found for $database/$input_name");
438                    $log->debug("parsed normalize rules:\n$rules");
439    
440                    # reset position in database
441                    $input_db->seek(1);
442    
443                    # generate name of config key for indexer (strip everything after -)
444                    my $indexer_config = $use_indexer;
445                    $indexer_config =~ s/^(\w+)-?.*$/$1/g if ($indexer_config);
446    
447                    my $lookup_hash;
448                    my $depends = $parser->depends($database,$input_name);
449            
450                    if ($depends) {
451                            $log->debug("$database/$input_name depends on: ", dump($depends)) if ($depends);
452                            $log->logdie("parser->depends didn't return HASH") unless (ref($depends) eq 'HASH');
453    
454                            foreach my $db (keys %$depends) {
455                                    foreach my $i (keys %{$depends->{$db}}) {
456                                            foreach my $k (keys %{$depends->{$db}->{$i}}) {
457                                                    my $t = time();
458                                                    $log->debug("loading lookup $db/$i");
459                                                    $lookup_hash->{$db}->{$i}->{$k} = $store->load_lookup(
460                                                            database => $db,
461                                                            input => $i,
462                                                            key => $k,
463                                                    );
464                                                    $log->debug(sprintf("lookup $db/$i took %.2fs", time() - $t));
465                                            }
466                                    }
467                            }
468    
469                            $log->debug("lookup_hash = ", sub { dump( $lookup_hash ) });
470                    }
471    
472    
473                  foreach my $pos ( 0 ... $input_db->size ) {                  foreach my $pos ( 0 ... $input_db->size ) {
474    
475                          my $row = $input_db->fetch || next;                          my $row = $input_db->fetch || next;
476    
477                            $total_rows++;
478    
479                          my $mfn = $row->{'000'}->[0];                          my $mfn = $row->{'000'}->[0];
480    
481                          if (! $mfn || $mfn !~ m#^\d+$#) {                          if (! $mfn || $mfn !~ m#^\d+$#) {
# Line 262  while (my ($database, $db_config) = each Line 484  while (my ($database, $db_config) = each
484                                  push @{ $row->{'000'} }, $pos;                                  push @{ $row->{'000'} }, $pos;
485                          }                          }
486    
                                   
                         my $ds;  
                         if ($n) {  
                                 $ds = $n->data_structure($row);  
                         } else {  
                                 $ds = WebPAC::Normalize::Set::data_structure(  
                                         row => $row,  
                                         rules => $rules,  
                                         lookup => $lookup->lookup_hash,  
                                 );  
487    
488                                  $db->save_ds(                          if ($validate) {
489                                          id => $mfn,                                  if ( my $errors = $validate->validate_rec( $row, $input_db->dump_ascii ) ) {
490                                          ds => $ds,                                          $log->error( "MFN $mfn validation error:\n",
491                                          prefix => $input->{name},                                                  $validate->report_error( $errors )
492                                  ) if ($ds && !$stats);                                          );
493                                    }
494                                    next;   # validation doesn't create any output
495                          }                          }
496    
497                            my $ds = WebPAC::Normalize::data_structure(
498                                    row => $row,
499                                    rules => $rules,
500                                    lookup => $lookup_hash,
501                                    config => create_ds_config( $db_config, $database, $input, $mfn ),
502                                    marc_encoding => 'utf-8',
503                                    load_row_coderef => sub {
504                                            my ($database,$input,$mfn) = @_;
505                                            return $store->load_row(
506                                                    database => $database,
507                                                    input => $input,
508                                                    id => $mfn,
509                                            );
510                                    },
511                            );
512    
513                            $log->debug("ds = ", sub { dump($ds) }) if ($ds);
514    
515                            $store->save_ds(
516                                    database => $database,
517                                    input => $input_name,
518                                    id => $mfn,
519                                    ds => $ds,
520                            ) if ($ds && !$stats);
521    
522                          $indexer->add(                          $indexer->add(
523                                  id => $input->{name} . "/" . $mfn,                                  id => "${input_name}/${mfn}",
524                                  ds => $ds,                                  ds => $ds,
525                                  type => $config->{$use_indexer}->{type},                                  type => $config->get($indexer_config)->{type},
526                          ) if ($indexer);                          ) if ($indexer && $ds);
527    
528                          $total_rows++;                          if ($marc) {
529                                    my $i = 0;
530    
531                                    while (my $fields = WebPAC::Normalize::_get_marc_fields( fetch_next => 1 ) ) {
532                                            $marc->add(
533                                                    id => $mfn . ( $i ? "/$i" : '' ),
534                                                    fields => $fields,
535                                                    leader => WebPAC::Normalize::marc_leader(),
536                                                    row => $row,
537                                            );
538                                            $i++;
539                                    }
540    
541                                    $log->info("Created $i instances of MFN $mfn\n") if ($i > 1);
542                            }
543                  }                  }
544    
545                  $log->info("statistics of fields usage:\n", $input_db->stats) if ($stats);                  if ($validate) {
546                            my $errors = $validate->report;
547                            if ($errors) {
548                                    $log->info("validation errors:\n$errors\n" );
549                                    print $report_fh "$errors\n" if ($report_fh);
550                            }
551                    }
552    
553                    if ($stats) {
554                            my $s = $input_db->stats;
555                            $log->info("statistics of fields usage:\n$s");
556                            print $report_fh "Statistics of fields usage:\n$s" if ($report_fh);
557                    }
558    
559          };                  # close MARC file
560                    $marc->finish if ($marc);
561    
562                    # close report
563                    close($report_fh) if ($report_fh)
564    
565            }
566    
567          eval { $indexer->finish } if ($indexer && $indexer->can('finish'));          eval { $indexer->finish } if ($indexer && $indexer->can('finish'));
568    
# Line 302  while (my ($database, $db_config) = each Line 573  while (my ($database, $db_config) = each
573                  )                  )
574          );          );
575    
576          #  
577          # add Hyper Estraier links to other databases          # end forked process
578          #          if ($parallel) {
579          if (ref($db_config->{links}) eq 'ARRAY') {                  $log->info("parallel process $$ finished");
580                  foreach my $link (@{ $db_config->{links} }) {                  exit(0);
                         if ($use_indexer eq 'hyperestraier') {  
                                 $log->info("adding link $database -> $link->{to} [$link->{credit}]");  
                                 $indexer->add_link(  
                                         from => $database,  
                                         to => $link->{to},  
                                         credit => $link->{credit},  
                                 );  
                         } else {  
                                 $log->warn("NOT IMPLEMENTED WITH $use_indexer: adding link $database -> $link->{to} [$link->{credit}]");  
                         }  
                 }  
581          }          }
582    
583  }  }
584    
585    if ($parallel) {
586            # wait all children to finish
587            sleep(1) while wait != -1;
588            $log->info("all parallel processes finished");
589    }
590    
591    #
592    # handle links or merge after indexing
593    #
594    
595    if ($merge) {
596            print $estcmd_fh 'sudo /etc/init.d/hyperestraier start',$/;
597            close($estcmd_fh);
598            chmod 0700, $estcmd_path || $log->warn("can't chmod 0700 $estcmd_path: $!");
599            system $estcmd_path;
600    } else {
601            foreach my $link (@links) {
602                    $log->logdie("coderef in link ", Dumper($link), " is ", ref($link), " and not CODE") unless (ref($link) eq 'CODE');
603                    $link->();
604            }
605    }

Legend:
Removed from v.512  
changed lines
  Added in v.775

  ViewVC Help
Powered by ViewVC 1.1.26