From b164e735ba2497ec5da29d61cc8ca7ef55306897 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 17 Jun 2016 11:42:56 -0400 Subject: [PATCH] hold targeter reify Signed-off-by: Bill Erickson --- Open-ILS/src/support-scripts/hold_targeter.pl | 41 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/support-scripts/hold_targeter.pl b/Open-ILS/src/support-scripts/hold_targeter.pl index 376d691685..a046238276 100755 --- a/Open-ILS/src/support-scripts/hold_targeter.pl +++ b/Open-ILS/src/support-scripts/hold_targeter.pl @@ -13,21 +13,36 @@ use OpenILS::Utils::HoldTargeter; #---------------------------------------------------------------- my $osrf_config = shift || '/openils/conf/opensrf_core.xml'; +my $lockfile = shift || "/tmp/hold_targeter-LOCK"; -OpenSRF::System->bootstrap_client(config_file => $osrf_config); -Fieldmapper->import( - IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL")); -OpenILS::Utils::CStoreEditor::init(); +if (-e $lockfile) { + die "I seem to be running already. If not remove $lockfile, try again\n"; +} -my $targeter = OpenILS::Utils::HoldTargeter->new; +open(F, ">$lockfile") or die "Cannot open lock file: $lockfile : $@\n"; +print F $$ or die "Cannot write to lock file: $lockfile : $@\n"; +close F; -my $start = time; -my $count = $targeter->target( - # Return only the number processed, - # instead of a result blob for each hold. - return_count => 1 -); +eval { # Make sure we can delete the lock file. -my $minutes = sprintf('%0.2f', (time - $start) / 60); + OpenSRF::System->bootstrap_client(config_file => $osrf_config); + Fieldmapper->import( + IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL")); + OpenILS::Utils::CStoreEditor::init(); + + my $targeter = OpenILS::Utils::HoldTargeter->new; + + my $start = time; + my $count = $targeter->target( + # Return only the number processed, + # instead of a result blob for each hold. + return_count => 1 + ); + + my $minutes = sprintf('%0.2f', (time - $start) / 60); + + print "Processed $count holds in $minutes minutes.\n"; +}; + +unlink $lockfile; -print "Processed $count holds in $minutes minutes.\n"; -- 2.11.0