View | Details | Raw Unified | Return to bug 37495
Collapse All | Expand All

(-)a/misc/cronjobs/plugins_nightly.pl (-9 / +22 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Try::Tiny qw( catch try );
5
use Getopt::Long qw( GetOptions );
6
use Pod::Usage   qw( pod2usage );
7
use Try::Tiny    qw( catch try );
6
8
7
use C4::Context;
9
use C4::Context;
8
use C4::Log qw( cronlogaction );
10
use C4::Log qw( cronlogaction );
Lines 10-23 use Koha::Logger; Link Here
10
use Koha::Plugins;
12
use Koha::Plugins;
11
use Koha::Script -cron;
13
use Koha::Script -cron;
12
14
13
my $command_line_options = join(" ",@ARGV);
15
my $command_line_options = join( " ", @ARGV );
14
cronlogaction({ info => $command_line_options });
16
cronlogaction( { info => $command_line_options } );
17
18
my $metadata;
19
my $help;
20
GetOptions(
21
    'm|metadata=s%' => \$metadata,
22
    'h|help'        => \$help,
23
) or pod2usage(2);
24
pod2usage(1) if $help;
15
25
16
my $logger = Koha::Logger->get();
26
my $logger = Koha::Logger->get();
17
if ( C4::Context->config("enable_plugins") ) {
27
if ( C4::Context->config("enable_plugins") ) {
18
    my @plugins = Koha::Plugins->new->GetPlugins(
28
    my @plugins = Koha::Plugins->new->GetPlugins(
19
        {
29
        {
20
            method => 'cronjob_nightly',
30
            method   => 'cronjob_nightly',
31
            metadata => $metadata,
21
        }
32
        }
22
    );
33
    );
23
34
Lines 27-34 if ( C4::Context->config("enable_plugins") ) { Link Here
27
            cronlogaction( { info => "$plugin_name" } );
38
            cronlogaction( { info => "$plugin_name" } );
28
            $plugin->cronjob_nightly();
39
            $plugin->cronjob_nightly();
29
            cronlogaction( { action => "End", info => "$plugin_name COMPLETED" } );
40
            cronlogaction( { action => "End", info => "$plugin_name COMPLETED" } );
30
        }
41
        } catch {
31
        catch {
32
            cronlogaction( { action => "Error", info => "$plugin_name FAILED with error: $_" } );
42
            cronlogaction( { action => "Error", info => "$plugin_name FAILED with error: $_" } );
33
            warn "$_";
43
            warn "$_";
34
            $logger->warn("$_");
44
            $logger->warn("$_");
Lines 36-42 if ( C4::Context->config("enable_plugins") ) { Link Here
36
    }
46
    }
37
}
47
}
38
48
39
cronlogaction({ action => 'End', info => "COMPLETED" });
49
cronlogaction( { action => 'End', info => "COMPLETED" } );
40
50
41
=head1 NAME
51
=head1 NAME
42
52
Lines 44-50 plugins_nightly.pl - Run nightly tasks specified by plugins Link Here
44
54
45
=head1 SYNOPSIS
55
=head1 SYNOPSIS
46
56
47
plugins_nightly.pl
57
plugins_nightly.pl [-m|--metadata key=value]
58
59
-m --metadata, repeatable, specify a metadata key and value to run only plugins
60
                           with nightly_cronjob methods and matching metadata.
61
                           e.g. plugins_nightly.pl -m name="My Awesome Plugin"
48
62
49
=head1 AUTHOR
63
=head1 AUTHOR
50
64
51
- 

Return to bug 37495