Skip to content

Commit

Permalink
BWS-PKG - Bug 31345: Add ability to exit process_message_queue.pl ear…
Browse files Browse the repository at this point in the history
…ly if any plugin before_send_messages hook fails

Sometimes it would be better for process_message_queue.pl to stop if a plugin hook fails rather than continue processing. It would be nice if that was a command line option.

Test Plan:
1) Install any plugin with a before_send_messages hook
2) Modify the plugin, add a 'die;' statement at the start of the
   before_send_messages method of the plugin.
3) Run process_message_queue.pl as usual
4) Note the exit code is 0
5) Run it again with the new -e setting
6) Note the exit code is 1

Signed-off-by: Brendan Lawlor <[email protected]>
Signed-off-by: Victor Grousset/tuxayo <[email protected]>
  • Loading branch information
kylemhall committed May 10, 2024
1 parent 76ac900 commit ad0158f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions misc/cronjobs/process_message_queue.pl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
my $where;
my @type;
my @letter_code;
my $exit_on_plugin_failure = 0;

my $command_line_options = join(" ",@ARGV);

Expand All @@ -48,6 +49,7 @@
't|type:s' => \@type,
'c|code:s' => \@letter_code,
'w|where:s' => \$where,
'e|exit-on-plugin-failure' => \$exit_on_plugin_failure,
);
my $usage = << 'ENDUSAGE';
Expand All @@ -67,6 +69,7 @@
-h --help: this message
-v --verbose: provides verbose output to STDOUT
-w --where: filter messages to send with additional conditions in the where clause
-e --exit-on-plugin-failure: if enabled, script will exit prematurely if any plugin before_send_messages hook fails
ENDUSAGE

die $usage if $help;
Expand Down Expand Up @@ -106,6 +109,7 @@
}
catch {
warn "$_";
exit 1 if $exit_on_plugin_failure;
};
}
}
Expand Down

0 comments on commit ad0158f

Please sign in to comment.