From 86d46ae03a040aecd76ecadef88fcb81e326dbfb Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 11 Apr 2024 07:52:53 +0200 Subject: [PATCH] Bug 30897: Limit to plack environments I had a feeling we'd want to do this when I submitted the proof of concept, though I hadn't appreciated the wider issues that have now been highlighted.. it makes a lot of sense to limit to the plack scope. --- Koha/Plugins.pm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm index 94ff5e991a5..0ffee023f89 100644 --- a/Koha/Plugins.pm +++ b/Koha/Plugins.pm @@ -364,17 +364,19 @@ sub RemovePlugins { sub _restart_after_change { my ( $class, $params ) = @_; - 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(); - } + 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(); + } - # Send SIGUSR1 signal to Plack parent process for graceful restart - kill 'HUP', $parent_pid; + # Send SIGUSR1 signal to Plack parent process for graceful restart + kill 'HUP', $parent_pid; + } } 1; -- 2.44.0