From dbc7791b7824c58216df73e00b3e4d50971278cc Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 24 Jul 2025 15:31:45 +0200 Subject: [PATCH] Bug 39740: Adjust koha-plack and koha-z3950-responder Content-Type: text/plain; charset=utf-8 Changes to koha-plack - Check is_test_system and -development for stack trace - Add check on set $environment for debugger - Move export to do_instance, remove three local's NOTE: GIT_INSTALL ie exported for koha-plack ONLY! The debian scripts call is_git_install. Changes to koha-z3950-responder - debugger needs test_system flag - Rearrange exports before calling start_z3950 and friends. Test plan: Check/adjust git_install and test_system in koha-conf.xml for used instances. cp debian/scripts/koha-functions.sh /usr/share/koha/bin/ cp debian/scripts/koha-* /usr/sbin/ cp debian/templates/plack.psgi /etc/koha/plack.psgi Add a die in e.g. opac/opac-main.pl. Set test_system to 1 in koha-conf.xml or export TEST_SYSTEM=1 in your environment. Restart Plack. Hit opac-main. Do you see a stack trace? Export TEST_SYSTEM=0. Restart Plack. Hit opac-main again. You should not see a stack trace. Start koha-z3950-responder with/without debug flag. Works as expected? Signed-off-by: Marcel de Rooy --- debian/scripts/koha-plack | 20 ++++++++++---------- debian/scripts/koha-z3950-responder | 22 +++++++++------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/debian/scripts/koha-plack b/debian/scripts/koha-plack index badf7270de..3e9816a400 100755 --- a/debian/scripts/koha-plack +++ b/debian/scripts/koha-plack @@ -92,14 +92,18 @@ start_plack() instance_user="${instancename}-koha" - if [ -z "$development_environment" ]; then environment="deployment"; else environment="development"; fi + if is_test_system ${instancename} || [ -n "$development_environment" ]; then + environment="development" + else + environment="deployment" + fi daemonize="--daemonize" logging="--access-log /var/log/koha/${instancename}/plack.log \ --error-log /var/log/koha/${instancename}/plack-error.log" max_requests_and_workers="--max-requests ${PLACK_MAX_REQUESTS} --workers ${PLACK_WORKERS}" - if [ "$debug_mode" = "yes" ]; then - # Maybe we should switch off debug_mode if GIT_INSTALL is not set? + # Enable debug mode in development + if [ "$debug_mode" = "yes" ] && [ "$environment" = "development" ]; then daemonize="" logging="" # remote debugger takes care max_requests_and_workers="--workers 1" @@ -363,12 +367,12 @@ set_action() _do_instance() { local name=$1 - local PERL5LIB=$PERL5LIB - local KOHA_HOME=$KOHA_HOME - local GIT_INSTALL=$GIT_INSTALL adjust_paths_git_install $name PERL5LIB=$PERL5LIB:$KOHA_HOME/installer:$KOHA_HOME/lib/installer + if [ "$KOHA_BINDIR" = "misc" ]; then GIT_INSTALL=1; else GIT_INSTALL=""; fi + export PERL5LIB KOHA_HOME GIT_INSTALL + # If debug mode is enabled, add the debugger lib path # to PERL5LIB if appropriate #FIXME: many of these variables should be set in a higher scope @@ -475,10 +479,6 @@ done [ "${quiet}" != "yes" ] && check_env_and_warn -export PERL5LIB -export GIT_INSTALL -export KOHA_HOME - if [ $# -gt 0 ]; then # We have at least one instance name for name in "$@"; do diff --git a/debian/scripts/koha-z3950-responder b/debian/scripts/koha-z3950-responder index c43493156b..d8c4a49add 100755 --- a/debian/scripts/koha-z3950-responder +++ b/debian/scripts/koha-z3950-responder @@ -86,15 +86,13 @@ start_z3950() logging="-l /var/log/koha/${instancename}/z3950.log" Z3950RESPONDER="/usr/bin/perl $KOHA_HOME/$KOHA_BINDIR/z3950_responder.pl" - if [ "$debug_mode" = "yes" ]; then - if [ "$GIT_INSTALL" = "1" ]; then - warn "Not a dev install, disabling debug mode" - else - environment="development" - daemonize="" - logging="" # remote debugger takes care - Z3950RESPONDER="/usr/bin/perl -d $KOHA_HOME/$KOHA_BINDIR/z3950_responder.pl" - fi + if [ "$debug_mode" = "yes" ] && is_test_system $instancename; then + environment="development" + daemonize="" + logging="" # remote debugger takes care + Z3950RESPONDER="/usr/bin/perl -d $KOHA_HOME/$KOHA_BINDIR/z3950_responder.pl" + elif [ "$debug_mode" = "yes" ]; then + warn "Not a test system, disabling debug mode" fi Z3950OPTS="-c ${CONFIGDIR} \ @@ -297,12 +295,10 @@ if [ $# -gt 0 ]; then if is_instance $name; then adjust_paths_git_install $name - export GIT_INSTALL - export KOHA_HOME PERL5LIB=$PERL5LIB:$KOHA_HOME/installer:$KOHA_HOME/lib/installer # If debug mode is enabled, add the debugger lib path # to PERL5LIB if appropriate - if [ "$debug_mode" = "yes" ]; then + if [ "$debug_mode" = "yes" ] && is_test_system $name; then if [ "$debugger_path" != "" ]; then PERL5LIB="${debugger_path}":$PERL5LIB fi @@ -311,7 +307,7 @@ if [ $# -gt 0 ]; then export DBGP_IDEKEY=${debugger_key} export PERL5OPT="-d" fi - export PERL5LIB + export KOHA_HOME PERL5LIB case $op in "start") -- 2.39.5