|
Lines 21-26
$|=1; # flushes output
Link Here
|
| 21 |
# If the cron job starts us in an unreadable dir, we will break without |
21 |
# If the cron job starts us in an unreadable dir, we will break without |
| 22 |
# this. |
22 |
# this. |
| 23 |
chdir $ENV{HOME} if (!(-r '.')); |
23 |
chdir $ENV{HOME} if (!(-r '.')); |
|
|
24 |
my $daemon_mode; |
| 25 |
my $daemon_sleep = 5; |
| 24 |
my $directory; |
26 |
my $directory; |
| 25 |
my $nosanitize; |
27 |
my $nosanitize; |
| 26 |
my $skip_export; |
28 |
my $skip_export; |
|
Lines 45-50
my $run_user = (getpwuid($<))[0];
Link Here
|
| 45 |
my $verbose_logging = 0; |
47 |
my $verbose_logging = 0; |
| 46 |
my $zebraidx_log_opt = " -v none,fatal,warn "; |
48 |
my $zebraidx_log_opt = " -v none,fatal,warn "; |
| 47 |
my $result = GetOptions( |
49 |
my $result = GetOptions( |
|
|
50 |
'daemon' => \$daemon_mode, |
| 51 |
'sleep:i' => \$daemon_sleep, |
| 48 |
'd:s' => \$directory, |
52 |
'd:s' => \$directory, |
| 49 |
'r|reset' => \$reset, |
53 |
'r|reset' => \$reset, |
| 50 |
's' => \$skip_export, |
54 |
's' => \$skip_export, |
|
Lines 152-167
if ($do_munge) {
Link Here
|
| 152 |
|
156 |
|
| 153 |
my $tester = XML::LibXML->new(); |
157 |
my $tester = XML::LibXML->new(); |
| 154 |
|
158 |
|
| 155 |
if ($authorities) { |
159 |
if ($daemon_mode) { |
| 156 |
index_records('authority', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir); |
160 |
while (1) { |
| 157 |
} else { |
161 |
do_one_pass() if ( zebraqueue_not_empty() ); |
| 158 |
print "skipping authorities\n" if ( $verbose_logging ); |
162 |
sleep $daemon_sleep; |
| 159 |
} |
163 |
} |
| 160 |
|
|
|
| 161 |
if ($biblios) { |
| 162 |
index_records('biblio', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $biblioserverdir); |
| 163 |
} else { |
164 |
} else { |
| 164 |
print "skipping biblios\n" if ( $verbose_logging ); |
165 |
do_one_pass(); |
| 165 |
} |
166 |
} |
| 166 |
|
167 |
|
| 167 |
|
168 |
|
|
Lines 191-196
if ($keep_export) {
Link Here
|
| 191 |
} |
192 |
} |
| 192 |
} |
193 |
} |
| 193 |
|
194 |
|
|
|
195 |
sub do_one_pass { |
| 196 |
if ($authorities) { |
| 197 |
index_records('authority', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir); |
| 198 |
} else { |
| 199 |
print "skipping authorities\n" if ( $verbose_logging ); |
| 200 |
} |
| 201 |
|
| 202 |
if ($biblios) { |
| 203 |
index_records('biblio', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $biblioserverdir); |
| 204 |
} else { |
| 205 |
print "skipping biblios\n" if ( $verbose_logging ); |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
# Check the zebra update queue and return true if there are records to process |
| 210 |
sub zebraqueue_not_empty { |
| 211 |
my $query = $dbh->prepare('SELECT COUNT(*) FROM zebraqueue WHERE done = 0;'); |
| 212 |
$query->execute; |
| 213 |
my $count = $query->fetchrow_arrayref->[0]; |
| 214 |
print "queued records: $count\n" if $verbose_logging > 0; |
| 215 |
return $count > 0; |
| 216 |
} |
| 217 |
|
| 194 |
# This checks to see if the zebra directories exist under the provided path. |
218 |
# This checks to see if the zebra directories exist under the provided path. |
| 195 |
# If they don't, then zebra is likely to spit the dummy. This returns true |
219 |
# If they don't, then zebra is likely to spit the dummy. This returns true |
| 196 |
# if the directories had to be created, false otherwise. |
220 |
# if the directories had to be created, false otherwise. |
|
Lines 692-697
Parameters:
Link Here
|
| 692 |
|
716 |
|
| 693 |
-a index authority records |
717 |
-a index authority records |
| 694 |
|
718 |
|
|
|
719 |
-daemon Run in daemon mode. The program will loop checking |
| 720 |
for entries on the zebraqueue table, processing |
| 721 |
them incrementally if present, and then sleep |
| 722 |
for a few seconds before repeating the process |
| 723 |
Checking the zebraqueue table is done with a cheap |
| 724 |
SQL query. This allows for near realtime update of |
| 725 |
the zebra search index with low system overhead. |
| 726 |
Use -sleep to control the checking interval. |
| 727 |
|
| 728 |
-sleep 10 Seconcds to sleep between checks of the zebraqueue |
| 729 |
table in daemon mode. The default is 5 seconds. |
| 730 |
|
| 695 |
-z select only updated and deleted |
731 |
-z select only updated and deleted |
| 696 |
records marked in the zebraqueue |
732 |
records marked in the zebraqueue |
| 697 |
table. Cannot be used with -r |
733 |
table. Cannot be used with -r |
| 698 |
- |
|
|