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

(-)a/misc/background_jobs_worker.pl (-2 / +51 lines)
Lines 15-26 Link Here
15
# You should have received a copy of the GNU General Public License
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
=head1 NAME
19
20
background_jobs_worker.pl - Worker script that will process backgroung jobs
21
22
=head1 SYNOPSIS
23
24
./background_jobs_worker.pl [--job-type]
25
26
=head1 DESCRIPTION
27
28
This script will connect to the Stomp server (RabbitMQ) and subscribe to the different destination queues available.
29
You can specify some queues only (using --job-type) if you want to run several workers that will handle their own jobs.
30
31
=head1 OPTIONS
32
33
=over
34
35
=item B<--job-type>
36
37
Give the job types this worker will process.
38
39
The different values available are:
40
41
    batch_biblio_record_modification
42
    batch_authority_record_modification
43
    update_elastic_index
44
45
=back
46
47
=cut
48
18
use Modern::Perl;
49
use Modern::Perl;
19
use JSON qw( encode_json decode_json );
50
use JSON qw( encode_json decode_json );
20
use Try::Tiny;
51
use Try::Tiny;
52
use Pod::Usage;
53
use Getopt::Long;
21
54
22
use Koha::BackgroundJobs;
55
use Koha::BackgroundJobs;
23
56
57
my ( $help, @job_types );
58
GetOptions(
59
    'h|help' => \$help,
60
    'job-type:s' => \@job_types,
61
) || pod2usage(1);
62
63
pod2usage(0) if $help;
64
24
my $conn;
65
my $conn;
25
try {
66
try {
26
    $conn = Koha::BackgroundJob->connect;
67
    $conn = Koha::BackgroundJob->connect;
Lines 28-39 try { Link Here
28
    warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
69
    warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
29
};
70
};
30
71
31
my @job_types = qw(
72
my @available_job_types = qw(
32
    batch_biblio_record_modification
73
    batch_biblio_record_modification
33
    batch_authority_record_modification
74
    batch_authority_record_modification
34
    update_elastic_index
75
    update_elastic_index
35
);
76
);
36
77
78
if ( @job_types ) {
79
    for my $job_type ( @job_types ) {
80
        pod2usage( -verbose => 1, -msg => sprintf "You specify an invalid --job-type value: %s\n", $job_type )
81
            unless grep { $_ eq $job_type } @available_job_types;
82
    }
83
} else {
84
    @job_types = @available_job_types;
85
}
86
37
if ( $conn ) {
87
if ( $conn ) {
38
    # FIXME cf note in Koha::BackgroundJob about $namespace
88
    # FIXME cf note in Koha::BackgroundJob about $namespace
39
    my $namespace = C4::Context->config('memcached_namespace');
89
    my $namespace = C4::Context->config('memcached_namespace');
40
- 

Return to bug 27344