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

(-)a/misc/cronjobs/process_message_queue.pl (-10 / +40 lines)
Lines 28-33 BEGIN { Link Here
28
use C4::Letters;
28
use C4::Letters;
29
use C4::Log;
29
use C4::Log;
30
use Getopt::Long;
30
use Getopt::Long;
31
use MIME::Lite;
32
use Mail::Sendmail;
33
use Encode;
34
35
use Fcntl ':flock';
31
36
32
my $username = undef;
37
my $username = undef;
33
my $password = undef;
38
my $password = undef;
Lines 68-81 die $usage if $help; Link Here
68
73
69
cronlogaction();
74
cronlogaction();
70
75
71
C4::Letters::SendQueuedMessages(
76
print "start of program\n";
72
    {
77
73
        verbose  => $verbose,
78
my $instancedirectory;
74
        username => $username,
79
foreach my $instance  (`koha-list --enabled`) {
75
        password => $password,
80
    my $instancemessagequeuefile = "/var/lock/koha/$instance/messagequeue.lock";
76
        method   => $method,
81
    open(FOO, ">> $instancemessagequeuefile") or die "Cannot write to $instancemessagequeuefile: $!";
77
        limit    => $limit,
82
    print "Getting the lock\n";
78
        type     => $type,
83
84
    unless (flock ( FOO, LOCK_EX|LOCK_NB )) {
85
        print "$0 is already running. Exiting.\n";
86
87
        #Send email to inform administrator another process_message_queue.pl cron was attempted to run whilst previous execution of the file is taking place. 
88
        # Configure accordingly
89
        my $email = MIME::Lite->build(
90
                To => ' ',
91
                From => ' ',
92
                Type => 'TEXT',
93
                Subject => 'process_message_queue.pl cron is already running',
94
                Data => 'process_message_queue.pl cron is already running',
95
                contenttype => 'charset="UTF-8"',
96
        );
97
        $email->send('smpt', ' ');
98
        exit(1);
79
    }
99
    }
80
);
81
100
82
- 
101
    C4::Letters::SendQueuedMessages(
102
        {
103
            verbose  => $verbose,
104
            username => $username,
105
            password => $password,
106
            method   => $method,
107
            limit    => $limit,
108
            type     => $type,
109
        }
110
    );
111
    print "End of process_message_queue.pl cron process";
112
}

Return to bug 15529