From 5793a29221cb9b687ec43381d6e1562d1b948e55 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 10 Apr 2020 19:37:31 -0300 Subject: [PATCH] Bug 25109: Add ->new and ->lock_exec to Koha::Script Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- Koha/Script.pm | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ t/Koha/Script.t | 27 +++++++++++++- t/Koha/sleep.pl | 19 ++++++++++ 3 files changed, 142 insertions(+), 1 deletion(-) create mode 100755 t/Koha/sleep.pl diff --git a/Koha/Script.pm b/Koha/Script.pm index 2126d18506..9cfbc9ecf8 100644 --- a/Koha/Script.pm +++ b/Koha/Script.pm @@ -35,7 +35,12 @@ This class should be used in all scripts. It sets the interface and userenv appr =cut +use File::Basename; +use Fcntl qw(:flock); + use C4::Context; +use Koha::Exceptions; +use Koha::Exceptions::Exception; sub import { my $class = shift; @@ -67,6 +72,98 @@ sub import { } } +=head1 API + +=head2 Class methods + +=head3 new + + my $script = Koha::Script->new( + { + script => $0, # mandatory + [ lock_name => 'my_script' ] + } + ); + +Create a new Koha::Script object. The I