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 $where_str; |
212 |
|
213 |
if ($authorities && $biblios) { |
214 |
$where_str = 'done = 0;'; |
215 |
} elsif ($biblios) { |
216 |
$where_str = 'server = "biblioserver" AND done = 0;'; |
217 |
} else { |
218 |
$where_str = 'server = "authorityserver" AND done = 0;'; |
219 |
} |
220 |
my $query = |
221 |
$dbh->prepare( 'SELECT COUNT(*) FROM zebraqueue WHERE ' . $where_str ); |
222 |
|
223 |
$query->execute; |
224 |
my $count = $query->fetchrow_arrayref->[0]; |
225 |
print "queued records: $count\n" if $verbose_logging > 0; |
226 |
return $count > 0; |
227 |
} |
228 |
|
194 |
# This checks to see if the zebra directories exist under the provided path. |
229 |
# 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 |
230 |
# 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. |
231 |
# if the directories had to be created, false otherwise. |
Lines 692-697
Parameters:
Link Here
|
692 |
|
727 |
|
693 |
-a index authority records |
728 |
-a index authority records |
694 |
|
729 |
|
|
|
730 |
-daemon Run in daemon mode. The program will loop checking |
731 |
for entries on the zebraqueue table, processing |
732 |
them incrementally if present, and then sleep |
733 |
for a few seconds before repeating the process |
734 |
Checking the zebraqueue table is done with a cheap |
735 |
SQL query. This allows for near realtime update of |
736 |
the zebra search index with low system overhead. |
737 |
Use -sleep to control the checking interval. |
738 |
|
739 |
-sleep 10 Seconds to sleep between checks of the zebraqueue |
740 |
table in daemon mode. The default is 5 seconds. |
741 |
|
695 |
-z select only updated and deleted |
742 |
-z select only updated and deleted |
696 |
records marked in the zebraqueue |
743 |
records marked in the zebraqueue |
697 |
table. Cannot be used with -r |
744 |
table. Cannot be used with -r |
698 |
- |
|
|