Bug 32736

Summary: koha-worker should be able to restart all queues with a single call
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: Command-line UtilitiesAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: Pushed to main --- QA Contact: Nick Clemens (kidclamp) <nick>
Severity: normal    
Priority: P5 - low CC: david, lucas, magnus, mtj, nick, robin, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Adds an --all-queues option to the koha-worker package command. This lets you perform actions (such as start, stop, restart, and status) on all defined queues (currently only 'default' and 'long_tasks') with one command.
Version(s) released in:
26.05.00
Circulation function:
Bug Depends on: 31124    
Bug Blocks: 35092    
Attachments: Bug 32736: Add --all-queues switch to koha-worker
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues
Bug 32736: Add --all-queues switch to koha-worker
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues
Bug 32736: Add --all-queues switch to koha-worker
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues
Bug 32736: Add --all-queues switch to koha-worker
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues
Bug 32736: Add --all-queues switch to koha-worker
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues

Description Nick Clemens (kidclamp) 2023-01-26 17:53:41 UTC
Maybe a --queue all or something?
Comment 1 Magnus Enger 2023-11-08 08:25:35 UTC
+1
Comment 2 Tomás Cohen Arazi (tcohen) 2025-05-21 19:56:04 UTC
Working in the area and this seems trivial with bug 31124 addition.
Comment 3 Tomás Cohen Arazi (tcohen) 2025-05-21 21:06:45 UTC
Created attachment 182708 [details] [review]
Bug 32736: Add --all-queues switch to koha-worker

This patch adds a convenient option switch to the script. It will make
it perform the action (start, stop, restart, print status) on all
defined queues ('default' and 'long_tasks', as of today).

To test, make sure you applied bug 31124:

0. Apply this patch
1. Run:
   $ ktd --shell --root
  k$ cp debian/scripts/koha-functions.sh \
        /usr/share/koha/bin/koha-functions.sh
2. Play with all the options for:

  k$ debian/scripts/koha-worker * kohadev
=> SUCCESS: All options work as expected!

Note: you should include (say) having `long_tasks` stopped, and starting
all workers with the new parameter. And the same for `--stop` and
`--start`.

3. Sign off :-D
Comment 4 Tomás Cohen Arazi (tcohen) 2025-05-21 21:11:40 UTC
Created attachment 182710 [details] [review]
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues
Comment 5 Magnus Enger 2025-05-22 06:29:03 UTC
Sorry: 

$ git bz apply 32736

Bug 32736 Depends on bug 31124 (Signed Off)
Follow? [(y)es, (n)o] y

Bug 31124 - koha-remove fails to remove long_tasks queue daemon, so koha-create for same <instance> user fails

182714 - Bug 31124: Make koha-remove stop all workers

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 31124: Make koha-remove stop all workers

Bug 32736 - koha-worker should be able to restart all queues with a single call

182708 - Bug 32736: Add --all-queues switch to koha-worker
182710 - Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 32736: Add --all-queues switch to koha-worker
Applying: Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues
error: sha1 information is lacking or useless (debian/scripts/koha-create).
error: could not build fake ancestor
Patch failed at 0001 Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-32736-follow-up-Make-scripts-using-koha-worker-NyF0sC.patch
Comment 6 Tomás Cohen Arazi (tcohen) 2025-08-07 20:58:44 UTC
Created attachment 185252 [details] [review]
Bug 32736: Add --all-queues switch to koha-worker

This patch adds a convenient option switch to the script. It will make
it perform the action (start, stop, restart, print status) on all
defined queues ('default' and 'long_tasks', as of today).

To test, make sure you applied bug 31124:

0. Apply this patch
1. Run:
   $ ktd --shell --root
  k$ cp debian/scripts/koha-functions.sh \
        /usr/share/koha/bin/koha-functions.sh
2. Play with all the options for:

  k$ debian/scripts/koha-worker * kohadev
=> SUCCESS: All options work as expected!

Note: you should include (say) having `long_tasks` stopped, and starting
all workers with the new parameter. And the same for `--stop` and
`--start`.

3. Sign off :-D
Comment 7 Tomás Cohen Arazi (tcohen) 2025-08-07 20:58:47 UTC
Created attachment 185253 [details] [review]
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues
Comment 8 David Nind 2025-12-26 17:00:16 UTC
The patch no longer applies 8-(...

git bz apply 32736

Bug 32736 - koha-worker should be able to restart all queues with a single call

185252 - Bug 32736: Add --all-queues switch to koha-worker
185253 - Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 32736: Add --all-queues switch to koha-worker
Using index info to reconstruct a base tree...
M	debian/scripts/koha-worker
Falling back to patching base and 3-way merge...
Auto-merging debian/scripts/koha-worker
CONFLICT (content): Merge conflict in debian/scripts/koha-worker
error: Failed to merge in the changes.
Patch failed at 0001 Bug 32736: Add --all-queues switch to koha-worker
Comment 9 Tomás Cohen Arazi (tcohen) 2025-12-26 18:05:42 UTC
Created attachment 190736 [details] [review]
Bug 32736: Add --all-queues switch to koha-worker

This patch adds a convenient option switch to the script. It will make
it perform the action (start, stop, restart, print status) on all
defined queues ('default' and 'long_tasks', as of today).

To test, make sure you applied bug 31124:

0. Apply this patch
1. Run:
   $ ktd --shell --root
  k$ cp debian/scripts/koha-functions.sh \
        /usr/share/koha/bin/koha-functions.sh
2. Play with all the options for:

  k$ debian/scripts/koha-worker * kohadev
=> SUCCESS: All options work as expected!

Note: you should include (say) having `long_tasks` stopped, and starting
all workers with the new parameter. And the same for `--stop` and
`--start`.

3. Sign off :-D
Comment 10 Tomás Cohen Arazi (tcohen) 2025-12-26 18:05:44 UTC
Created attachment 190737 [details] [review]
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues

Patch from commit cad1ee2
Comment 11 David Nind 2025-12-26 19:18:24 UTC
Created attachment 190738 [details] [review]
Bug 32736: Add --all-queues switch to koha-worker

This patch adds a convenient option switch to the script. It will make
it perform the action (start, stop, restart, print status) on all
defined queues ('default' and 'long_tasks', as of today).

To test, make sure you applied bug 31124:

0. Apply this patch
1. Run:
   $ ktd --shell --root
  k$ cp debian/scripts/koha-functions.sh \
        /usr/share/koha/bin/koha-functions.sh
2. Play with all the options for:

  k$ debian/scripts/koha-worker * kohadev
=> SUCCESS: All options work as expected!

Note: you should include (say) having `long_tasks` stopped, and starting
all workers with the new parameter. And the same for `--stop` and
`--start`.

3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 12 David Nind 2025-12-26 19:18:28 UTC
Created attachment 190739 [details] [review]
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues

Signed-off-by: David Nind <david@davidnind.com>
Comment 13 David Nind 2025-12-26 19:41:31 UTC
Testing notes (using KTD):

1. After applying the patch, I ran reset_all

2. Running koha-worker --help now shows the new options

3. I tested some of the options, and they all seemed to work okay for me:
   - sudo koha-worker --stop --all-queues kohadev
   - sudo koha-worker --status kohadev
   - sudo koha-worker --status --all-queues kohadev
   - sudo koha-worker --start --queue default kohadev
   - sudo koha-worker --status --all-queues kohadev
   - sudo koha-worker --start --all-queues kohadev
   - sudo koha-worker --start --all-queues kohadev
   - sudo koha-worker --restart --all-queues kohadev
   - sudo koha-worker --stop --queue long_tasks kohadev


For reference, the updated help with the new --all-queues option:

koha-worker

This script lets you manage the worker daemon for your Koha instances.

Usage:
koha-worker [--start|--stop|--restart] [--queue queue_name|--all-queues] [--quiet|-q] instancename1 [instancename2...]
koha-worker --status instancename1 [instancename2...]
koha-worker -h|--help

    --start               Start the worker daemon for the specified instances
    --stop                Stop the worker daemon for the specified instances
    --restart             Restart the worker daemon for the specified instances
    --queue               Specify the queue/worker to perform the action on - 'default' is
                          used if not specified (unless --all-queues is passed)
                          current queues are: default, long_tasks
    --all-queues          Perform the action on all defined queues
    --status              Show the status of the worker for the specified instances
    --quiet|-q            Make the script quiet about non existent instance names
                          (useful for calling from another scripts).
    --help|-h             Display this help message

Note: There used to be a queue called elastic_index, but since the introduction
of koha-es-indexer this queue should not be active.
Comment 14 Nick Clemens (kidclamp) 2026-01-09 16:51:44 UTC
Created attachment 191209 [details] [review]
Bug 32736: Add --all-queues switch to koha-worker

This patch adds a convenient option switch to the script. It will make
it perform the action (start, stop, restart, print status) on all
defined queues ('default' and 'long_tasks', as of today).

To test, make sure you applied bug 31124:

0. Apply this patch
1. Run:
   $ ktd --shell --root
  k$ cp debian/scripts/koha-functions.sh \
        /usr/share/koha/bin/koha-functions.sh
2. Play with all the options for:

  k$ debian/scripts/koha-worker * kohadev
=> SUCCESS: All options work as expected!

Note: you should include (say) having `long_tasks` stopped, and starting
all workers with the new parameter. And the same for `--stop` and
`--start`.

3. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 15 Nick Clemens (kidclamp) 2026-01-09 16:51:47 UTC
Created attachment 191210 [details] [review]
Bug 32736: (follow-up) Make scripts using koha-worker use --all-queues

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 16 Lucas Gass (lukeg) 2026-01-12 17:28:35 UTC
Nice work everyone!

Pushed to main for 26.05