Bug 27783: Add --job-type to background_jobs_worker.pl
This will let sysop adjust the number of workers and how they want to manage them. For instance one could want to have one worker for ES indexation and another worker for other jobs, to prevent ES index to be stuck behind bigger batch process. Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
1269a074fc
commit
a42717ad15
1 changed files with 52 additions and 1 deletions
|
@ -15,12 +15,53 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
background_jobs_worker.pl - Worker script that will process background jobs
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
./background_jobs_worker.pl [--job-type]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This script will connect to the Stomp server (RabbitMQ) and subscribe to the different destination queues available.
|
||||
You can specify some queues only (using --job-type) if you want to run several workers that will handle their own jobs.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over
|
||||
|
||||
=item B<--job-type>
|
||||
|
||||
Give the job types this worker will process.
|
||||
|
||||
The different values available are:
|
||||
|
||||
batch_biblio_record_modification
|
||||
batch_authority_record_modification
|
||||
update_elastic_index
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
use Modern::Perl;
|
||||
use JSON qw( decode_json );
|
||||
use Try::Tiny qw( catch try );
|
||||
use Pod::Usage;
|
||||
use Getopt::Long;
|
||||
|
||||
use Koha::BackgroundJobs;
|
||||
|
||||
my ( $help, @job_types );
|
||||
GetOptions(
|
||||
'h|help' => \$help,
|
||||
'job-type:s' => \@job_types,
|
||||
) || pod2usage(1);
|
||||
|
||||
pod2usage(0) if $help;
|
||||
|
||||
my $conn;
|
||||
try {
|
||||
$conn = Koha::BackgroundJob->connect;
|
||||
|
@ -28,7 +69,7 @@ try {
|
|||
warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
|
||||
};
|
||||
|
||||
my @job_types = qw(
|
||||
my @available_job_types = qw(
|
||||
batch_biblio_record_modification
|
||||
batch_authority_record_modification
|
||||
batch_item_record_modification
|
||||
|
@ -36,8 +77,18 @@ my @job_types = qw(
|
|||
batch_authority_record_deletion
|
||||
batch_item_record_deletion
|
||||
batch_hold_cancel
|
||||
update_elastic_index
|
||||
);
|
||||
|
||||
if ( @job_types ) {
|
||||
for my $job_type ( @job_types ) {
|
||||
pod2usage( -verbose => 1, -msg => sprintf "You specify an invalid --job-type value: %s\n", $job_type )
|
||||
unless grep { $_ eq $job_type } @available_job_types;
|
||||
}
|
||||
} else {
|
||||
@job_types = @available_job_types;
|
||||
}
|
||||
|
||||
if ( $conn ) {
|
||||
# FIXME cf note in Koha::BackgroundJob about $namespace
|
||||
my $namespace = C4::Context->config('memcached_namespace');
|
||||
|
|
Loading…
Reference in a new issue