ad4afc2e2093b1ed87063bdcdf54b6b962382b01
[Evergreen.git] / Open-ILS / src / support-scripts / hold_targeter.pl
1 #!/usr/bin/perl
2 # ---------------------------------------------------------------------
3 # Usage:
4 #   hold_targeter.pl <config_file> <lock_file>
5 # ---------------------------------------------------------------------
6
7 use strict; 
8 use warnings;
9 use JSON;
10 use OpenSRF::System;
11
12 my $config = shift || die "bootstrap config required\n";
13 my $lockfile = shift || "/tmp/hold_targeter-LOCK";
14
15 if (-e $lockfile) {
16         die "I seem to be running already at pid $pid.  If not remove $lockfile, try again\n";
17 }
18
19 open(F, ">$lockfile");
20 print F $$;
21 close F;
22
23 OpenSRF::System->bootstrap_client( config_file => $config );
24
25 my $r = OpenSRF::AppSession
26                 ->create( 'open-ils.storage' )
27                 ->request( 'open-ils.storage.action.hold_request.copy_targeter' => '24h' );
28
29 while (!$r->complete) { $r->recv };
30
31 unlink $lockfile;
32