From dfd72b292939d41319c20768d124fb27ca86a672 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 11 Apr 2024 10:28:07 +0200 Subject: [PATCH] Bug 30897: Add option to disable automated restart This patch adds the ability to disable the automated plack restart we introduce with this patchset via configuration. Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer --- Koha/Plugins.pm | 22 +++++++++---------- debian/templates/koha-conf-site.xml.in | 1 + etc/koha-conf.xml | 1 + .../prog/en/modules/plugins/plugins-upload.tt | 5 +++++ plugins/plugins-upload.pl | 2 ++ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index 0ffee023f8..88c51a5e6f 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -364,19 +364,19 @@ sub RemovePlugins { sub _restart_after_change { my ( $class, $params ) = @_; - if ( C4::Context->psgi_env ) { - my $parent_pid = getpid(); - my $ppid = getppid(); # Get the parent process ID - - # If the current process is not Plack parent, find the parent process recursively - while ( $parent_pid != $ppid ) { - $parent_pid = $ppid; - $ppid = getppid(); - } + return unless ( C4::Context->config('plugins_restart') && C4::Context->psgi_env ); + + my $parent_pid = getpid(); + my $ppid = getppid(); # Get the parent process ID - # Send SIGUSR1 signal to Plack parent process for graceful restart - kill 'HUP', $parent_pid; + # If the current process is not Plack parent, find the parent process recursively + while ( $parent_pid != $ppid ) { + $parent_pid = $ppid; + $ppid = getppid(); } + + # Send SIGUSR1 signal to Plack parent process for graceful restart + kill 'HUP', $parent_pid; } 1; diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in index c35b6d8432..b4e3c71ba2 100644 --- a/debian/templates/koha-conf-site.xml.in +++ b/debian/templates/koha-conf-site.xml.in @@ -409,6 +409,7 @@ __END_SRU_PUBLICSERVER__ 0 0 1 + 0