Bug 23700 - Fix output of koha-plack --restart
Summary: Fix output of koha-plack --restart
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Magnus Enger
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-30 12:27 UTC by Magnus Enger
Modified: 2020-06-04 20:35 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00
Circulation function:


Attachments
Bug 23700 - Fix output of koha-plack --restart (1.39 KB, patch)
2019-09-30 13:09 UTC, Magnus Enger
Details | Diff | Splinter Review
Very nicely aligned now. (1.44 KB, patch)
2019-10-01 07:34 UTC, Jesse Maseto
Details | Diff | Splinter Review
Bug 23700 - Fix output of koha-plack --restart (1.54 KB, patch)
2019-10-18 12:49 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2019-09-30 12:27:15 UTC
When you run "koha-plack --restart" the output is not well aligned:

$ sudo koha-plack --restart kohadev
[ ok ] Restarting Plack daemon for kohadev:[....] Stopping Plack daemon for kohadev:.
[ ok ] Starting Plack daemon for kohadev:.
. ok
Comment 1 Magnus Enger 2019-09-30 13:00:44 UTC
It looks like problem is here:

 166         log_daemon_msg "Restarting Plack daemon for ${instancename}"
 167 
 168         if stop_plack $instancename && start_plack $instancename; then
 169             log_end_msg 0
 170         else
 171             log_end_msg 1
 172         fi

We call log_daemon_msg on line 166, then we call the corresponding log_end_msg on lines 169 or 171. But in between we call stop_plack and start_plack, which do their own output through log_daemon_msg/log_end_msg, causing the out of line output. 

I can see a couple of solutions to this:

1. Call log_daemon_msg inside the if:

        if stop_plack $instancename && start_plack $instancename; then
            log_daemon_msg "Restarted Plack daemon for ${instancename}"
            log_end_msg 0
        else
            log_daemon_msg "Could not restart Plack daemon for ${instancename}"
            log_end_msg 1
        fi

This gives output like this:

$ sudo koha-plack --restart kohadev
[ ok ] Stopping Plack daemon for kohadev:.
[ ok ] Starting Plack daemon for kohadev:.
[ ok ] Restarted Plack daemon for kohadev:.

2. Don't call log_daemon_msg at all:

          stop_plack $instancename && start_plack $instancename

This gives us:

$ sudo koha-plack --restart kohadev
[ ok ] Stopping Plack daemon for kohadev:.
[ ok ] Starting Plack daemon for kohadev:.

stop_plack and start_plack will each tell us what they do and if they succeed or not, so do we really need that third line? 

I will submit a patch for the second solution, but I'm happy to make a patch for the first solution, if that is the preferred way.
Comment 2 Magnus Enger 2019-09-30 13:09:53 UTC
Created attachment 93244 [details] [review]
Bug 23700 - Fix output of koha-plack --restart

To test:
- Run "sudo koha-plack restart kohadev" and verify the output is
  out of line.
- Apply the patch
- If you are on e.g. kohadevbox you need to copy koha-plack to
  /usr/sbin/ thus:
  sudo cp debian/scripts/koha-plack /usr/sbin/koha-plack
- Run "sudo koha-plack restart kohadev" again and check that you
  get two lines of output, nicely aligned with the "OK" inside the
  square brackets.
Comment 3 Jesse Maseto 2019-10-01 07:34:50 UTC
Created attachment 93344 [details] [review]
Very nicely aligned now.

Bug 23700 - Fix output of koha-plack --restart

To test:
- Run "sudo koha-plack restart kohadev" and verify the output is
  out of line.
- Apply the patch
- If you are on e.g. kohadevbox you need to copy koha-plack to
  /usr/sbin/ thus:
  sudo cp debian/scripts/koha-plack /usr/sbin/koha-plack
- Run "sudo koha-plack restart kohadev" again and check that you
  get two lines of output, nicely aligned with the "OK" inside the
  square brackets.

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Comment 4 Marcel de Rooy 2019-10-18 12:49:31 UTC
Created attachment 94409 [details] [review]
Bug 23700 - Fix output of koha-plack --restart

To test:
- Run "sudo koha-plack restart kohadev" and verify the output is
  out of line.
- Apply the patch
- If you are on e.g. kohadevbox you need to copy koha-plack to
  /usr/sbin/ thus:
  sudo cp debian/scripts/koha-plack /usr/sbin/koha-plack
- Run "sudo koha-plack restart kohadev" again and check that you
  get two lines of output, nicely aligned with the "OK" inside the
  square brackets.

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 5 Martin Renvoize (ashimema) 2019-10-21 08:46:09 UTC
Nice work!

Pushed to master for 19.11.00