From 1fafc03d546d0344b3fd5d5308d8498da5c0be43 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 21 May 2025 16:26:31 -0300 Subject: [PATCH] Bug 31124: Make koha-remove stop all workers This patch makes two things: * Adds a `get_worker_queues` function to koha-functions.sh * Makes `koha-remove` loop through all the defined queues to stop all the running workers before trying to remove the unix user for the instance. To test: 1. Run: $ ktd --shell k$ sudo -s k$ koha-create test1 k$ service koha-common restart k$ koha-remove test1 => FAIL: There's an error about not being able to drop the instance user 2. Run: k$ ps -ef | grep test1 => FAIL: There's a running process for the 'long_tasks' queue worker. 3. Apply this patch 4. Run: k$ cp debian/scripts/koha-functions.sh \ /usr/share/koha/bin/koha-functions.sh 5. Repeat 1 naming the instance `test2` => SUCCESS: The instance is removed correctly. No error about running processes => SUCCESS: No process is running for `test2` 6. Sign off :-D --- debian/scripts/koha-functions.sh | 7 +++++++ debian/scripts/koha-remove | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index b31b1c67909..90ccf1611e0 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -242,6 +242,13 @@ get_worker_name() fi } +get_worker_queues() +{ + for queue in default long_tasks; do + echo $queue + done; +} + is_plack_enabled_opac() { local instancefile=$1 diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove index a6653e02f82..96eff08d4c6 100755 --- a/debian/scripts/koha-remove +++ b/debian/scripts/koha-remove @@ -81,10 +81,12 @@ eof if is_indexer_running $name; then koha-indexer --stop $name || /bin/true fi - # Stop the worker daemon if needed - if is_worker_running $name; then - koha-worker --stop $name || /bin/true - fi + # Stop the worker daemons if needed + for queue in $(get_worker_queues); do + if is_worker_running $name $queue; then + koha-worker --queue $queue --stop $name|| /bin/true + fi + done # Stop the Plack server if needed if is_plack_running $name; then koha-plack --stop $name || /bin/true -- 2.49.0