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 C4::Context; |
31 |
|
32 |
|
32 |
my $username = undef; |
33 |
my $username = undef; |
33 |
my $password = undef; |
34 |
my $password = undef; |
Lines 37-42
my $help = 0;
Link Here
|
37 |
my $verbose = 0; |
38 |
my $verbose = 0; |
38 |
my $type = q{}; |
39 |
my $type = q{}; |
39 |
|
40 |
|
|
|
41 |
use MIME::Lite; |
42 |
use Mail::Sendmail; |
43 |
use Encode; |
44 |
use Net::SMTP; |
45 |
|
46 |
use Fcntl ':flock'; |
47 |
|
48 |
|
40 |
GetOptions( |
49 |
GetOptions( |
41 |
'u|username:s' => \$username, |
50 |
'u|username:s' => \$username, |
42 |
'p|password:s' => \$password, |
51 |
'p|password:s' => \$password, |
Lines 68-81
die $usage if $help;
Link Here
|
68 |
|
77 |
|
69 |
cronlogaction(); |
78 |
cronlogaction(); |
70 |
|
79 |
|
71 |
C4::Letters::SendQueuedMessages( |
80 |
print "start of program\n"; |
72 |
{ |
81 |
my $logdir = C4::Context->config('logdir'); |
73 |
verbose => $verbose, |
82 |
|
74 |
username => $username, |
83 |
chomp $logdir; |
75 |
password => $password, |
84 |
my $instancemessagequeuefile = $logdir . "/messagequeue.lock"; |
76 |
method => $method, |
85 |
open(FOO, ">> $instancemessagequeuefile") or die "Cannot write to $instancemessagequeuefile: $!"; |
77 |
limit => $limit, |
86 |
|
78 |
type => $type, |
87 |
print "Getting the lock\n"; |
79 |
} |
88 |
unless (flock ( FOO, LOCK_EX|LOCK_NB )) { |
|
|
89 |
|
90 |
print "$0 is already running. Exiting.\n"; |
91 |
#Send email to inform administrator another process_message_queue.pl cron was attempted to run whilst previous execution of the file is taking place. |
92 |
# Configure accordingly |
93 |
MIME::Lite->send( 'smtp', ''); |
94 |
my $email = MIME::Lite->new( |
95 |
To => ' ', |
96 |
From => ' ', |
97 |
Type => 'TEXT', |
98 |
Subject => 'process_message_queue.pl cron is already running', |
99 |
Data => 'process_message_queue.pl cron is already running', |
100 |
); |
101 |
|
102 |
$email->attach( |
103 |
Type => 'Text', |
104 |
Data => 'process_message_queue.pl cron is already running', |
80 |
); |
105 |
); |
|
|
106 |
$email->send(); |
107 |
exit(1); |
108 |
} |
81 |
|
109 |
|
82 |
- |
110 |
C4::Letters::SendQueuedMessages( { verbose => $verbose, username => $username, password => $password, method => $method } ); |
|
|
111 |
sleep(15); |
112 |
print "End of process_message_queue.pl cron process"; |