/[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 291 by dpavlin, Sun Dec 18 23:34:24 2005 UTC revision 301 by dpavlin, Mon Dec 19 21:26:04 2005 UTC
# Line 15  use WebPAC::Normalize::XML; Line 15  use WebPAC::Normalize::XML;
15  use WebPAC::Output::TT;  use WebPAC::Output::TT;
16  use WebPAC::Output::Estraier 0.05;  use WebPAC::Output::Estraier 0.05;
17  use YAML qw/LoadFile/;  use YAML qw/LoadFile/;
18  use LWP::Simple;  use Getopt::Long;
19    use File::Path;
20    
21  my $limit = shift @ARGV;  =head1 NAME
22    
23  my $config = LoadFile('conf/config.yml');  run.pl - start WebPAC indexing
24    
25  print "config = ",Dumper($config);  B<this command will probably go away. Don't get used to it!>
26    
27    Options:
28    
29    =over 4
30    
31    =item --offset 42
32    
33    start loading (all) databases at offset 42
34    
35    =item --limit 100
36    
37    limit loading to 100 records
38    
39    =item --clean
40    
41    remove database and Hyper Estraier index before indexing
42    
43    =item --config conf/config.yml
44    
45    path to YAML configuration file
46    
47    =back
48    
49    =cut
50    
51    my $offset;
52    my $limit;
53    
54    my $clean = 0;
55    my $config = 'conf/config.yml';
56    my $debug = 0;
57    
58    GetOptions(
59            "limit=i" => \$limit,
60            "offset=i" => \$offset,
61            "clean" => \$clean,
62            "config" => \$config,
63            "debug" => \$debug,
64    );
65    
66    $config = LoadFile($config);
67    
68    print "config = ",Dumper($config) if ($debug);
69    
70  die "no databases in config file!\n" unless ($config->{databases});  die "no databases in config file!\n" unless ($config->{databases});
71    
# Line 38  while (my ($database, $db_config) = each Line 82  while (my ($database, $db_config) = each
82          my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");          my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
83          $est_config->{database} = $database;          $est_config->{database} = $database;
84    
         $log->info("using HyperEstraier URL $est_config->{masterurl}");  
   
85          my $est = new WebPAC::Output::Estraier(          my $est = new WebPAC::Output::Estraier(
86                  %{ $est_config },                  %{ $est_config },
87          );          );
88    
89            if ($clean) {
90                    $log->warn("creating new empty index $database");
91                    $est->master( action => 'nodedel', name => $database );
92                    $est->master( action => 'nodeadd', name => $database, label => $database );
93            }
94    
95          #          #
96          # now WebPAC::Store          # now WebPAC::Store
97          #          #
# Line 52  while (my ($database, $db_config) = each Line 100  while (my ($database, $db_config) = each
100    
101          my $db_path = $config->{webpac}->{db_path} . '/' . $database;          my $db_path = $config->{webpac}->{db_path} . '/' . $database;
102    
103          $log->info("working on $database in $db_path");          if ($clean) {
104                    $log->info("creating new database $database in $db_path");
105                    rmtree( $db_path ) || $log->warn("can't remove $db_path: $!");
106            } else {
107                    $log->info("working on $database in $db_path");
108            }
109    
110          my $db = new WebPAC::Store(          my $db = new WebPAC::Store(
111                  path => $db_path,                  path => $db_path,
112                  database => $database,                  database => $database,
113                  debug => 1,                  debug => $debug,
114          );          );
115    
116    
# Line 93  while (my ($database, $db_config) = each Line 146  while (my ($database, $db_config) = each
146                  my $input_db = new WebPAC::Input(                  my $input_db = new WebPAC::Input(
147                          module => $input_module,                          module => $input_module,
148                          code_page => $config->{webpac}->{webpac_encoding},                          code_page => $config->{webpac}->{webpac_encoding},
149                          limit => $input->{limit},                          limit => $limit || $input->{limit},
150                            offset => $offset,
151                          lookup => $lookup,                          lookup => $lookup,
152                  );                  );
153                  $log->logdie("can't create input using $input_module") unless ($input);                  $log->logdie("can't create input using $input_module") unless ($input);

Legend:
Removed from v.291  
changed lines
  Added in v.301

  ViewVC Help
Powered by ViewVC 1.1.26