From fa7037d23529dc260e4ff5c0c42af6d08c9a577e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 23 Jul 2012 13:50:09 -0400 Subject: [PATCH] acq order reader; continuing Signed-off-by: Bill Erickson --- Open-ILS/examples/opensrf.xml.example | 2 +- Open-ILS/src/support-scripts/acq_order_reader.pl | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example index 05891ae2d1..508fe88162 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -277,7 +277,7 @@ vim:et:ts=4:sw=4: - ALL + ALL diff --git a/Open-ILS/src/support-scripts/acq_order_reader.pl b/Open-ILS/src/support-scripts/acq_order_reader.pl index da72226657..ba0e2aa74c 100755 --- a/Open-ILS/src/support-scripts/acq_order_reader.pl +++ b/Open-ILS/src/support-scripts/acq_order_reader.pl @@ -53,6 +53,9 @@ my %defaults = ( 'poll-interval=i' => 10 ); +# ----------------------------------------------------- +# Command-line args reading / munging +# ----------------------------------------------------- $OpenILS::Utils::Cronscript::debug=1 if $debug; $Getopt::Long::debug=1 if $debug > 1; my $o = OpenILS::Utils::Cronscript->new(\%defaults); @@ -105,7 +108,11 @@ if ($debug) { } } -print Dumper($real_opts); +$debug and print Dumper($real_opts); + +# ----------------------------------------------------- +# subs +# ----------------------------------------------------- # log in sub new_auth_token { @@ -159,16 +166,19 @@ sub push_file_to_acq { # TODO: delete tmp queue? } +my %org_cache; sub org_from_sn { my $sn = shift; + return $org_cache{$sn} if $org_cache{$sn}; my $org = $editor->search_actor_org_unit({shortname => $sn})->[0]; if (!$org) { warn "No such org unit in acq_order_reader config: '$sn'\n"; return undef; } - return $org; + return $org_cache{$sn} = $org; } +# translate config info into a request arguments structure sub args_from_provider_conf { my $conf = shift; my %args; @@ -211,7 +221,7 @@ sub args_from_provider_conf { $args{vandelay}->{$opt} = $vconf->{$opt} } - # boolean options + # bool options for my $opt ( qw/ create_assets @@ -316,14 +326,16 @@ while (1) { clear_auth_token(); $logger->info("acq-or: loop processed $processed files"); - $debug and print "Sleeping for $poll_interval seconds...\n"; $SIG{INT} = sub { print "Cleaning up...\n"; exit; # allows lockfile cleanup }; - sleep $poll_interval; + # processing takes time. If we processed any records + # during the current iteration, immediately check again + # for more work. Otherwise, wait $poll_interval seconds + sleep $poll_interval if $processed == 0; } __END__ -- 2.11.0