|
Lines 21-26
use Modern::Perl;
Link Here
|
| 21 |
|
21 |
|
| 22 |
use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; |
22 |
use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; |
| 23 |
use constant DEFAULT_ELASTICQ_PURGEDAYS => 30; |
23 |
use constant DEFAULT_ELASTICQ_PURGEDAYS => 30; |
|
|
24 |
use constant DEFAULT_JOBS_PURGEDAYS => 30; |
| 24 |
use constant DEFAULT_MAIL_PURGEDAYS => 30; |
25 |
use constant DEFAULT_MAIL_PURGEDAYS => 30; |
| 25 |
use constant DEFAULT_IMPORT_PURGEDAYS => 60; |
26 |
use constant DEFAULT_IMPORT_PURGEDAYS => 60; |
| 26 |
use constant DEFAULT_LOGS_PURGEDAYS => 180; |
27 |
use constant DEFAULT_LOGS_PURGEDAYS => 180; |
|
Lines 121-126
my $sess_days;
Link Here
|
| 121 |
my $verbose; |
122 |
my $verbose; |
| 122 |
my $zebraqueue_days; |
123 |
my $zebraqueue_days; |
| 123 |
my $elasticqueue_days; |
124 |
my $elasticqueue_days; |
|
|
125 |
my $jobsqueue_days; |
| 124 |
my $mail; |
126 |
my $mail; |
| 125 |
my $purge_merged; |
127 |
my $purge_merged; |
| 126 |
my $pImport; |
128 |
my $pImport; |
|
Lines 164-169
GetOptions(
Link Here
|
| 164 |
'm|mail:i' => \$mail, |
166 |
'm|mail:i' => \$mail, |
| 165 |
'zebraqueue:i' => \$zebraqueue_days, |
167 |
'zebraqueue:i' => \$zebraqueue_days, |
| 166 |
'elasticqueue:i' => \$elasticqueue_days, |
168 |
'elasticqueue:i' => \$elasticqueue_days, |
|
|
169 |
'jobsqueue:i' => \$jobsqueue_days, |
| 167 |
'merged' => \$purge_merged, |
170 |
'merged' => \$purge_merged, |
| 168 |
'import:i' => \$pImport, |
171 |
'import:i' => \$pImport, |
| 169 |
'z3950' => \$pZ3950, |
172 |
'z3950' => \$pZ3950, |
|
Lines 202-207
$sessions = 1 if $sess_days
Link Here
|
| 202 |
$pImport = DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport == 0; |
205 |
$pImport = DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport == 0; |
| 203 |
$pLogs = DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs == 0; |
206 |
$pLogs = DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs == 0; |
| 204 |
$zebraqueue_days = DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days == 0; |
207 |
$zebraqueue_days = DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days == 0; |
|
|
208 |
$elasticqueue_days = DEFAULT_ELASTICQ_PURGEDAYS if defined($elasticqueue_days) && $elasticqueue_days == 0; |
| 209 |
$jobsqueue_days = DEFAULT_JOBS_PURGEDAYS if defined($jobsqueue_days) && $jobsqueue_days == 0; |
| 205 |
$mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail == 0; |
210 |
$mail = DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail == 0; |
| 206 |
$pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; |
211 |
$pSearchhistory = DEFAULT_SEARCHHISTORY_PURGEDAYS if defined($pSearchhistory) && $pSearchhistory == 0; |
| 207 |
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0; |
212 |
$pListShareInvites = DEFAULT_SHARE_INVITATION_EXPIRY_DAYS if defined($pListShareInvites) && $pListShareInvites == 0; |
|
Lines 215-220
if ($help) {
Link Here
|
| 215 |
unless ( $sessions |
220 |
unless ( $sessions |
| 216 |
|| $zebraqueue_days |
221 |
|| $zebraqueue_days |
| 217 |
|| $elasticqueue_days |
222 |
|| $elasticqueue_days |
|
|
223 |
|| $jobsqueue_days |
| 218 |
|| $mail |
224 |
|| $mail |
| 219 |
|| $purge_merged |
225 |
|| $purge_merged |
| 220 |
|| $pImport |
226 |
|| $pImport |
|
Lines 329-334
if ($elasticqueue_days) {
Link Here
|
| 329 |
} |
335 |
} |
| 330 |
} |
336 |
} |
| 331 |
|
337 |
|
|
|
338 |
if ($jobsqueue_days) { |
| 339 |
my $count = 0; |
| 340 |
print "Background jobs queue purge triggered for $jobsqueue_days days.\n" if $verbose; |
| 341 |
$sth = $dbh->prepare( |
| 342 |
q{ |
| 343 |
DELETE FROM background_jobs |
| 344 |
WHERE status='finished' AND ended_on < date_sub(curdate(), INTERVAL ? DAY) |
| 345 |
} |
| 346 |
); |
| 347 |
if ( $confirm ) { |
| 348 |
$sth->execute($jobsqueue_days) or die $dbh->errstr; |
| 349 |
$count = $sth->rows; |
| 350 |
} |
| 351 |
if ( $verbose ) { |
| 352 |
say $confirm ? "$count jobs were deleted from the background jobs queue." : "All entries from backgorund jobs queue would have been deleted"; |
| 353 |
say "Done with background jobs queue purge."; |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 332 |
if ($mail) { |
357 |
if ($mail) { |
| 333 |
my $count = 0; |
358 |
my $count = 0; |
| 334 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
359 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
| 335 |
- |
|
|