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

(-)a/C4/SIP/ILS.pm (-2 / +2 lines)
Lines 196-202 sub test_cardnumber_compare { Link Here
196
}
196
}
197
197
198
sub checkin {
198
sub checkin {
199
    my ( $self, $item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel, $account ) = @_;
199
    my ( $self, $item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel, $account, $no_block ) = @_;
200
200
201
    my $checked_in_ok     = $account->{checked_in_ok};
201
    my $checked_in_ok     = $account->{checked_in_ok};
202
    my $cv_triggers_alert = $account->{cv_triggers_alert};
202
    my $cv_triggers_alert = $account->{cv_triggers_alert};
Lines 211-217 sub checkin { Link Here
211
211
212
    my $data;
212
    my $data;
213
    if ($item) {
213
    if ($item) {
214
        $data = $circ->do_checkin( $current_loc, $return_date, $account );
214
        $data = $circ->do_checkin( $current_loc, $return_date, $account, $no_block );
215
    }
215
    }
216
    else {
216
    else {
217
        $circ->alert(1);
217
        $circ->alert(1);
(-)a/C4/SIP/Sip/MsgType.pm (-7 / +2 lines)
Lines 670-682 sub handle_checkin { Link Here
670
    $ils->check_inst_id( $inst_id, "handle_checkin" );
670
    $ils->check_inst_id( $inst_id, "handle_checkin" );
671
671
672
    if ( $no_block eq 'Y' ) {
672
    if ( $no_block eq 'Y' ) {
673
673
        siplog( "LOG_WARNING", "received no-block checkin from terminal '%s'", $account->{id} );
674
        # Off-line transactions, ick.
674
        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account, $no_block );
675
        siplog( "LOG_WARNING", "received no-block checkin from terminal '%s' - no-block checkin not supported", $account->{id} );
676
        #FIXME We need to write the routine called below
677
        #$status = $ils->checkin_no_block( $item_id, $trans_date, $return_date, $item_props, $cancel );
678
        #Until we do, lets just checkin the item
679
        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account );
680
    } else {
675
    } else {
681
        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account );
676
        $status = $ils->checkin( $item_id, $trans_date, $return_date, $my_branch, $item_props, $cancel, $account );
682
    }
677
    }
(-)a/misc/background_jobs_worker.pl (-19 / +11 lines)
Lines 52-62 use JSON qw( decode_json ); Link Here
52
use Try::Tiny qw( catch try );
52
use Try::Tiny qw( catch try );
53
use Pod::Usage;
53
use Pod::Usage;
54
use Getopt::Long;
54
use Getopt::Long;
55
use Parallel::ForkManager;
55
56
56
use Koha::BackgroundJobs;
57
use Koha::BackgroundJobs;
57
58
58
my ( $help, @queues );
59
my ( $help, @queues );
60
my $max_processes = 10;
59
GetOptions(
61
GetOptions(
62
    'm|max-processes=i' => \$max_processes,
60
    'h|help' => \$help,
63
    'h|help' => \$help,
61
    'queue=s' => \@queues,
64
    'queue=s' => \@queues,
62
) || pod2usage(1);
65
) || pod2usage(1);
Lines 74-79 try { Link Here
74
    warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
77
    warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_;
75
};
78
};
76
79
80
my $pm = Parallel::ForkManager->new($max_processes);
81
77
if ( $conn ) {
82
if ( $conn ) {
78
    # FIXME cf note in Koha::BackgroundJob about $namespace
83
    # FIXME cf note in Koha::BackgroundJob about $namespace
79
    my $namespace = C4::Context->config('memcached_namespace');
84
    my $namespace = C4::Context->config('memcached_namespace');
Lines 96-127 while (1) { Link Here
96
        # It could work in a first step, but then we will want to handle job that will be created from the message received
101
        # It could work in a first step, but then we will want to handle job that will be created from the message received
97
        my $job = Koha::BackgroundJobs->find($args->{job_id});
102
        my $job = Koha::BackgroundJobs->find($args->{job_id});
98
103
99
        process_job( $job, $args );
104
        $pm->start and next;
105
        $job->process( { job_id => $job->id, %$args } );
100
        $conn->ack( { frame => $frame } ); # FIXME depending on success?
106
        $conn->ack( { frame => $frame } ); # FIXME depending on success?
107
        $pm->finish;
101
108
102
    } else {
109
    } else {
103
        my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues });
110
        my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues });
104
        while ( my $job = $jobs->next ) {
111
        while ( my $job = $jobs->next ) {
112
            $pm->start and next;
105
            my $args = $job->json->decode($job->data);
113
            my $args = $job->json->decode($job->data);
106
            process_job( $job, { job_id => $job->id, %$args } );
114
            $job->process( { job_id => $job->id, %$args } );
115
            $pm->finish;
107
        }
116
        }
108
        sleep 10;
117
        sleep 10;
109
    }
118
    }
110
}
119
}
111
$conn->disconnect;
120
$conn->disconnect;
112
113
sub process_job {
114
    my ( $job, $args ) = @_;
115
116
    my $pid;
117
    if ( $pid = fork ) {
118
        wait;
119
        return;
120
    }
121
122
    die "fork failed!" unless defined $pid;
123
124
    $job->process( $args );
125
126
    exit;
127
}
128
- 

Return to bug 32558