Bugzilla – Attachment 19710 Details for
Bug 6435
[ENH] Added daemon mode parameters to rebuild_zebra.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Improved patch to add daemon mode to rebuild_zebra.pl
rebuild_zebra.diff (text/plain), 4.84 KB, created by
Doug Kingston
on 2013-07-17 04:09:00 UTC
(
hide
)
Description:
Improved patch to add daemon mode to rebuild_zebra.pl
Filename:
MIME Type:
Creator:
Doug Kingston
Created:
2013-07-17 04:09:00 UTC
Size:
4.84 KB
patch
obsolete
>*** rebuild_zebra.pl 2013-05-23 05:30:30.000000000 +0100 >--- rebuild_zebra2.pl 2013-07-17 05:02:38.000000000 +0100 >*************** >*** 22,27 **** >--- 22,29 ---- > # If the cron job starts us in an unreadable dir, we will break without > # this. > chdir $ENV{HOME} if (!(-r '.')); >+ my $daemon_mode; >+ my $daemon_sleep = 5; > my $directory; > my $nosanitize; > my $skip_export; >*************** >*** 43,53 **** > my $verbose_logging = 0; > my $zebraidx_log_opt = " -v none,fatal,warn "; > my $result = GetOptions( > 'd:s' => \$directory, > 'r|reset' => \$reset, > 's' => \$skip_export, > 'k' => \$keep_export, >! 'I|skip-index' => \$skip_index, > 'nosanitize' => \$nosanitize, > 'b' => \$biblios, > 'noxml' => \$noxml, >--- 45,57 ---- > my $verbose_logging = 0; > my $zebraidx_log_opt = " -v none,fatal,warn "; > my $result = GetOptions( >+ 'daemon' => \$daemon_mode, >+ 'sleep:i' => \$daemon_sleep, > 'd:s' => \$directory, > 'r|reset' => \$reset, > 's' => \$skip_export, > 'k' => \$keep_export, >! 'I|skip-index' => \$skip_index, > 'nosanitize' => \$nosanitize, > 'b' => \$biblios, > 'noxml' => \$noxml, >*************** >*** 55,67 **** > 'munge-config' => \$do_munge, > 'a' => \$authorities, > 'h|help' => \$want_help, >! 'x' => \$as_xml, > 'y' => \$do_not_clear_zebraqueue, > 'z' => \$process_zebraqueue, >! 'where:s' => \$where, >! 'length:i' => \$length, > 'offset:i' => \$offset, >! 'v+' => \$verbose_logging, > ); > > >--- 59,71 ---- > 'munge-config' => \$do_munge, > 'a' => \$authorities, > 'h|help' => \$want_help, >! 'x' => \$as_xml, > 'y' => \$do_not_clear_zebraqueue, > 'z' => \$process_zebraqueue, >! 'where:s' => \$where, >! 'length:i' => \$length, > 'offset:i' => \$offset, >! 'v+' => \$verbose_logging, > ); > > >*************** >*** 143,166 **** > > my $tester = XML::LibXML->new(); > >! if ($authorities) { >! index_records('authority', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir); >! } else { >! print "skipping authorities\n" if ( $verbose_logging ); >! } >! >! if ($biblios) { >! index_records('biblio', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $biblioserverdir); > } else { >! print "skipping biblios\n" if ( $verbose_logging ); > } > >- > if ( $verbose_logging ) { > print "====================\n"; > print "CLEANING\n"; > print "====================\n"; > } > if ($keep_export) { > print "NOTHING cleaned : the export $directory has been kept.\n"; > print "You can re-run this script with the -s "; >--- 147,167 ---- > > my $tester = XML::LibXML->new(); > >! if ($daemon_mode) { >! while(1) { >! do_one_pass() if ( zebraqueue_not_empty() ); >! sleep $daemon_sleep; >! } > } else { >! do_one_pass(); > } > > if ( $verbose_logging ) { > print "====================\n"; > print "CLEANING\n"; > print "====================\n"; > } >+ > if ($keep_export) { > print "NOTHING cleaned : the export $directory has been kept.\n"; > print "You can re-run this script with the -s "; >*************** >*** 182,187 **** >--- 183,213 ---- > } > } > >+ sub do_one_pass { >+ print "do_one_pass has work to do\n"; >+ >+ if ($authorities) { >+ index_records('authority', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir); >+ } else { >+ print "skipping authorities\n" if ( $verbose_logging ); >+ } >+ >+ if ($biblios) { >+ index_records('biblio', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $biblioserverdir); >+ } else { >+ print "skipping biblios\n" if ( $verbose_logging ); >+ } >+ } >+ >+ # Check the zebra update queue and return true if there are records to process >+ sub zebraqueue_not_empty { >+ my $query = $dbh->prepare('SELECT COUNT(*) FROM zebraqueue WHERE done = 0'); >+ $query->execute; >+ my $count = $query->fetchrow_arrayref->[0]; >+ print "queued records: $count\n" if $verbose_logging > 0; >+ return $count > 0; >+ } >+ > # This checks to see if the zebra directories exist under the provided path. > # If they don't, then zebra is likely to spit the dummy. This returns true > # if the directories had to be created, false otherwise.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6435
:
19267
|
19710
|
20574
|
20575
|
21097
|
21099
|
21390
|
21391
|
22039
|
22040
|
22080
|
22201
|
22457
|
22851
|
22859
|
22986