Bug 39911: Trap DIE signals in SIP server

At some point our SIP server stopped logging fatal errors to either logs or standard error. We should restore this vital functionality.

Test Plan:
1) Apply the first patch which will cause the patron information request
   to fail
2) Stop the SIP server
3) Start it again with: perl /kohadevbox/koha/C4/SIP/SIPServer.pm /etc/koha/sites/kohadev/SIPconfig.xml
4) Trigger the failure with the following command:
   ./misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su koha -sp koha -l MPL --patron koha -m patron_information
5) Note "THIS IS A TEST" is not found in logs or stderr
6) Apply the second patch
7) Repeat steps 2-4
8) Note the error message is now visible from stderr at the command line
   and also in the SIP log

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit f214db14dd)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Kyle M Hall 2025-05-15 13:25:18 -04:00 committed by Paul Derscheid
parent ce008cf965
commit 7c06904612
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 8 additions and 0 deletions

View File

@ -56,4 +56,12 @@ sub BINMODE {
binmode( STDOUT, $mode );
}
$SIG{__DIE__} = sub {
my $msg = shift;
my $logger = Koha::Logger->get( { interface => 'sip', category => 'STDERR' } );
$logger->error($msg) if $logger;
warn $msg; # die doesn't output the message, warn before dying
die $msg;
};
1;