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 <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-04-11 10:28:07 +02:00 committed by Katrin Fischer
parent 57ee369e90
commit dfd72b2929
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
5 changed files with 19 additions and 10 deletions

View File

@ -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
return unless ( C4::Context->config('plugins_restart') && C4::Context->psgi_env );
# If the current process is not Plack parent, find the parent process recursively
while ( $parent_pid != $ppid ) {
$parent_pid = $ppid;
$ppid = getppid();
}
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;

View File

@ -409,6 +409,7 @@ __END_SRU_PUBLICSERVER__
<dev_install>0</dev_install>
<strict_sql_modes>0</strict_sql_modes>
<plugins_restricted>1</plugins_restricted>
<plugins_restart>0</plugins_restart>
<plugin_repos>
<!--
<repo>

View File

@ -228,6 +228,7 @@
<dev_install>0</dev_install>
<strict_sql_modes>0</strict_sql_modes>
<plugins_restricted>1</plugins_restricted>
<plugins_restart>0</plugins_restart>
<plugin_repos>
<repo>
<name>ByWater Solutions</name>

View File

@ -44,6 +44,11 @@
[% END %]
</div>
[% END %]
[% IF ( !plugins_restart ) %]
<div class="dialog alert">
<strong>Your system is not configured to automatically refresh on plugin upload, you may need to ask your administrator to complete the plugin installation.</strong>
</div>
[% END %]
<form method="post" action="/cgi-bin/koha/plugins/plugins-upload.pl" enctype="multipart/form-data">
[% INCLUDE 'csrf-token.inc' %]
<fieldset class="brief">

View File

@ -33,6 +33,7 @@ use Koha::Plugins;
my $plugins_enabled = C4::Context->config("enable_plugins");
my $plugins_restricted = C4::Context->config("plugins_restricted");
my $plugins_restart = C4::Context->config("plugins_restart");
my $input = CGI->new;
my $uploadlocation = $input->param('uploadlocation');
@ -47,6 +48,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
flagsrequired => { plugins => 'manage' },
}
);
$template->param( plugins_restart => $plugins_restart );
# Early exist if uploads are not enabled direct upload attempted when uploads are restricted
if (!$plugins_enabled) {