Lines 55-60
GetOptions(
Link Here
|
55 |
'v|verbose' => \$verbose, |
55 |
'v|verbose' => \$verbose, |
56 |
't|type' => \$type, |
56 |
't|type' => \$type, |
57 |
); |
57 |
); |
|
|
58 |
|
59 |
sub usage { |
60 |
pod2usage( -verbose => 2 ); |
61 |
exit; |
62 |
} |
63 |
|
58 |
my $usage = << 'ENDUSAGE'; |
64 |
my $usage = << 'ENDUSAGE'; |
59 |
|
65 |
|
60 |
This script processes the message queue in the message_queue database |
66 |
This script processes the message queue in the message_queue database |
Lines 70-76
This script has the following parameters :
Link Here
|
70 |
-l --limit: The maximum number of messages to process for this run |
76 |
-l --limit: The maximum number of messages to process for this run |
71 |
-m --method: authentication method required by SMTP server (See perldoc Sendmail.pm for supported authentication types.) |
77 |
-m --method: authentication method required by SMTP server (See perldoc Sendmail.pm for supported authentication types.) |
72 |
-h --help: this message |
78 |
-h --help: this message |
73 |
-v --verbose: provides verbose output to STDOUT |
79 |
-v --verbose: provides verbose output to STDOUT, if verbose is set then emails will be sent upon duplicate execution of this cronjob |
74 |
ENDUSAGE |
80 |
ENDUSAGE |
75 |
|
81 |
|
76 |
die $usage if $help; |
82 |
die $usage if $help; |
Lines 87-110
open(FOO, ">> $instancemessagequeuefile") or die "Cannot write to $instancemessa
Link Here
|
87 |
print "Getting the lock\n"; |
93 |
print "Getting the lock\n"; |
88 |
unless (flock ( FOO, LOCK_EX|LOCK_NB )) { |
94 |
unless (flock ( FOO, LOCK_EX|LOCK_NB )) { |
89 |
|
95 |
|
90 |
print "$0 is already running. Exiting.\n"; |
96 |
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. |
97 |
#If verbose is set 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 |
98 |
# Configure accordingly |
93 |
MIME::Lite->send( 'smtp', ''); |
99 |
|
94 |
my $email = MIME::Lite->new( |
100 |
if ($verbose) { |
95 |
To => ' ', |
101 |
MIME::Lite->send( 'smtp', ''); |
96 |
From => ' ', |
102 |
my $email = MIME::Lite->new( |
97 |
Type => 'TEXT', |
103 |
To => ' ', |
98 |
Subject => 'process_message_queue.pl cron is already running', |
104 |
From => ' ', |
99 |
Data => 'process_message_queue.pl cron is already running', |
105 |
Type => 'TEXT', |
100 |
); |
106 |
Subject => 'process_message_queue.pl cron is already running', |
101 |
|
107 |
Data => 'process_message_queue.pl cron is already running', |
102 |
$email->attach( |
108 |
); |
103 |
Type => 'Text', |
109 |
|
104 |
Data => 'process_message_queue.pl cron is already running', |
110 |
$email->attach( |
105 |
); |
111 |
Type => 'Text', |
106 |
$email->send(); |
112 |
Data => 'process_message_queue.pl cron is already running', |
107 |
exit(1); |
113 |
); |
|
|
114 |
$email->send(); |
115 |
exit(1); |
116 |
} |
108 |
} |
117 |
} |
109 |
|
118 |
|
110 |
C4::Letters::SendQueuedMessages( { verbose => $verbose, username => $username, password => $password, method => $method } ); |
119 |
C4::Letters::SendQueuedMessages( { verbose => $verbose, username => $username, password => $password, method => $method } ); |
111 |
- |
|
|