|
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 |
use Net::SMTP; |
| 35 |
|
| 36 |
use Fcntl ':flock'; |
| 31 |
|
37 |
|
| 32 |
my $username = undef; |
38 |
my $username = undef; |
| 33 |
my $password = undef; |
39 |
my $password = undef; |
|
Lines 68-81
die $usage if $help;
Link Here
|
| 68 |
|
74 |
|
| 69 |
cronlogaction(); |
75 |
cronlogaction(); |
| 70 |
|
76 |
|
| 71 |
C4::Letters::SendQueuedMessages( |
77 |
print "start of program\n"; |
| 72 |
{ |
78 |
|
| 73 |
verbose => $verbose, |
79 |
foreach my $instance (`koha-list --enabled`) { |
| 74 |
username => $username, |
80 |
chomp $instance; |
| 75 |
password => $password, |
81 |
my $instancemessagequeuefile = "/var/lock/koha/" . $instance . "/messagequeue.lock"; |
| 76 |
method => $method, |
82 |
|
| 77 |
limit => $limit, |
83 |
|
| 78 |
type => $type, |
84 |
open(FOO, ">> $instancemessagequeuefile") or die "Cannot write to $instancemessagequeuefile: $!"; |
|
|
85 |
print "Getting the lock\n"; |
| 86 |
|
| 87 |
unless (flock ( FOO, LOCK_EX|LOCK_NB )) { |
| 88 |
print "$0 is already running. Exiting.\n"; |
| 89 |
|
| 90 |
#Send email to inform administrator another process_message_queue.pl cron was attempted to run whilst previous execution of the file is taking place. |
| 91 |
# Configure accordingly |
| 92 |
MIME::Lite->send( 'smtp', 'mail.catalyst.net.nz'); |
| 93 |
|
| 94 |
|
| 95 |
my $email = MIME::Lite->new( |
| 96 |
To => ' ', |
| 97 |
From => ' ', |
| 98 |
Type => 'TEXT', |
| 99 |
Subject => 'process_message_queue.pl cron is already running', |
| 100 |
Data => 'process_message_queue.pl cron is already running', |
| 101 |
); |
| 102 |
|
| 103 |
$email->attach( |
| 104 |
Type => 'Text', |
| 105 |
Data => 'process_message_queue.pl cron is already running', |
| 106 |
); |
| 107 |
|
| 108 |
$email->send(); |
| 109 |
exit(1); |
| 79 |
} |
110 |
} |
| 80 |
); |
|
|
| 81 |
|
111 |
|
| 82 |
- |
112 |
C4::Letters::SendQueuedMessages( |
|
|
113 |
{ |
| 114 |
verbose => $verbose, |
| 115 |
username => $username, |
| 116 |
password => $password, |
| 117 |
method => $method, |
| 118 |
limit => $limit, |
| 119 |
type => $type, |
| 120 |
} |
| 121 |
); |
| 122 |
print "End of process_message_queue.pl cron process"; |
| 123 |
} |