/[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 335 by dpavlin, Sat Dec 31 14:00:36 2005 UTC
# Line 13  use WebPAC::Input 0.03; Line 13  use WebPAC::Input 0.03;
13  use WebPAC::Store 0.03;  use WebPAC::Store 0.03;
14  use WebPAC::Normalize::XML;  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.08;
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 --one=database_name
44    
45    reindex just single database
46    
47    =item --config conf/config.yml
48    
49    path to YAML configuration file
50    
51    =back
52    
53    =cut
54    
55    my $offset;
56    my $limit;
57    
58    my $clean = 0;
59    my $config = 'conf/config.yml';
60    my $debug = 0;
61    my $one_db_name;
62    
63    GetOptions(
64            "limit=i" => \$limit,
65            "offset=i" => \$offset,
66            "clean" => \$clean,
67            "one=s" => \$one_db_name,
68            "config" => \$config,
69            "debug" => \$debug,
70    );
71    
72    $config = LoadFile($config);
73    
74    print "config = ",Dumper($config) if ($debug);
75    
76  die "no databases in config file!\n" unless ($config->{databases});  die "no databases in config file!\n" unless ($config->{databases});
77    
# Line 29  my $total_rows = 0; Line 79  my $total_rows = 0;
79    
80  while (my ($database, $db_config) = each %{ $config->{databases} }) {  while (my ($database, $db_config) = each %{ $config->{databases} }) {
81    
82            next if ($one_db_name && $database !~ m/$one_db_name/i);
83    
84          my $log = _new WebPAC::Common()->_get_logger();          my $log = _new WebPAC::Common()->_get_logger();
85    
86          #          #
# Line 37  while (my ($database, $db_config) = each Line 89  while (my ($database, $db_config) = each
89    
90          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");
91          $est_config->{database} = $database;          $est_config->{database} = $database;
92            $est_config->{clean} = $clean;
93    
94          $log->info("using HyperEstraier URL $est_config->{masterurl}");          my $est = new WebPAC::Output::Estraier( %{ $est_config } );
   
         my $est = new WebPAC::Output::Estraier(  
                 %{ $est_config },  
         );  
95    
96          #          #
97          # now WebPAC::Store          # now WebPAC::Store
# Line 52  while (my ($database, $db_config) = each Line 101  while (my ($database, $db_config) = each
101    
102          my $db_path = $config->{webpac}->{db_path} . '/' . $database;          my $db_path = $config->{webpac}->{db_path} . '/' . $database;
103    
104          $log->info("working on $database in $db_path");          if ($clean) {
105                    $log->info("creating new database $database in $db_path");
106                    rmtree( $db_path ) || $log->warn("can't remove $db_path: $!");
107            } else {
108                    $log->info("working on $database in $db_path");
109            }
110    
111          my $db = new WebPAC::Store(          my $db = new WebPAC::Store(
112                  path => $db_path,                  path => $db_path,
113                  database => $database,                  database => $database,
114                  debug => 1,                  debug => $debug,
115          );          );
116    
117    
# Line 93  while (my ($database, $db_config) = each Line 147  while (my ($database, $db_config) = each
147                  my $input_db = new WebPAC::Input(                  my $input_db = new WebPAC::Input(
148                          module => $input_module,                          module => $input_module,
149                          code_page => $config->{webpac}->{webpac_encoding},                          code_page => $config->{webpac}->{webpac_encoding},
150                          limit => $input->{limit},                          limit => $limit || $input->{limit},
151                            offset => $offset,
152                          lookup => $lookup,                          lookup => $lookup,
153                  );                  );
154                  $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.335

  ViewVC Help
Powered by ViewVC 1.1.26