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