From e0f1110389055b7a2fab960d398c04f895586120 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 11 Aug 2022 05:26:36 +0000 Subject: [PATCH] Bug 21366: Add koha-plack --reload to gracefully restart Plack/Starman This patch adds a "--reload" option to koha-plack, which allows a sysadmin to gracefully restart Koha. This is very useful when installing Koha plugins or deploying a hot fix where you need to change code but don't want to interrupt anyone's usage of Koha. 0. Apply patch 1. cp /usr/sbin/koha-plack /usr/sbin/koha-plack.bak 2. cp debian/scripts/koha-plack /usr/sbin/koha-plack 3. ps -efww | grep "starman" 4. Now at roughly the same time do the following two actions: 4a. Go to http://localhost:8081/cgi-bin/koha/about.pl 4b. koha-plack --reload kohadev 5. Note that the web request completes successfully 6. ps -efww | grep "starman" 7. Note that the "starman master" process stays alive, but the "starman worker" processes have been restarted Signed-off-by: Jonathan Druart Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- debian/scripts/koha-plack | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/debian/scripts/koha-plack b/debian/scripts/koha-plack index 497d6ffe53..649355bbb7 100755 --- a/debian/scripts/koha-plack +++ b/debian/scripts/koha-plack @@ -169,6 +169,26 @@ restart_plack() fi } +reload_plack() +{ + local instancename=$1 + + local PIDFILE="/var/run/koha/${instancename}/plack.pid" + + if is_plack_running ${instancename}; then + log_daemon_msg "Reloading Plack daemon for ${instancename}" + + if start-stop-daemon --pidfile ${PIDFILE} --user="${instancename}-koha" --stop --signal HUP; then + log_end_msg 0 + else + log_end_msg 1 + fi + else + log_daemon_msg "Error: Plack not running for ${instancename}" + log_end_msg 1 + fi +} + enable_plack() { local instancename=$1 @@ -360,6 +380,9 @@ _do_instance() { "restart") restart_plack $name ;; + "reload") + reload_plack $name + ;; "enable") enable_plack $name ;; @@ -398,6 +421,9 @@ while [ $# -gt 0 ]; do --restart) set_action "restart" shift ;; + --reload) + set_action "reload" + shift ;; --enable) set_action "enable" shift ;; -- 2.39.5