View | Details | Raw Unified | Return to bug 6435
Collapse All | Expand All

(-)a/misc/migration_tools/rebuild_zebra.pl (-10 / +33 lines)
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.
197
- 

Return to bug 6435