[Koha-bugs] [Bug 31729] Enable automatic filesystem refresh in Plack

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Aug 21 03:29:43 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31729

David Cook <dcook at prosentient.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #154605|0                           |1
        is obsolete|                            |

--- Comment #42 from David Cook <dcook at prosentient.com.au> ---
Created attachment 154676
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=154676&action=edit
Bug 31729: enable plackup hot restart in ktd

This patch implements a more idiomatoic way for hot-reloading. Instead
of adding a new daemon/watcher+inotify or use a Middleware, we can use
`plackup -R /path/to/dir`, which is the standard Perl way to do hot
reloading for plack apps.

Instead of calling `/usr/bin/perl starman` directly, we use
`plackup -s Starman`. And can then use `-R /kohadevbox/koha/Koha` to
watch that directory for changes and hot-reload the plack app.

I've added a new option `koha-plack --hot-reload`. Only if this option
is set AND we're running inside koha-testing-docker (by checking
KOHA_INSTANCE = "kohadev") hot reloading is enabled.

Test plan:

Before applying the patch:

* Start koha-testing-docker and enter the container

* Stop plack: koha-plack --stop kohadev

* Check the log: tail -n 4 /var/log/koha/kohadev/plack-error.log
  You should see lines like
    Worker processes cleaned up
    Server closing!

* Start it again: koha-plack --start kohadev
  Output should be "Starting Plack daemon for kohadev:"
  And you end back at the interactive shell

* Check the log: tail -n 4 /var/log/koha/kohadev/plack-error.log
  it should look like:
    Starman::Server (type Net::Server::PreFork) starting!
    Binding to UNIX socket file "/var/run/koha/kohadev/plack.sock"
    Starman: Accepting connections at
unix://localhost:/var/run/koha/kohadev/plack.sock/

* Stop it again: koha-plack --stop kohadev

Now apply the patch.

As in koha-testing-docker the koha-plack script (after applying the
patch) is NOT installed to /sbin you have to call the dev version.

* Start the server with hot-reloading:
  debian/scripts/koha-plack --start --hot-reload kohadev

* Output should be:
  Starting Plack daemon for kohadev:Watching /kohadevbox/koha/Koha
/etc/koha/sites/kohadev/plack.psgi for file updates.

* You are now NOT back in the shell, as the plack app is NOT running
  daemonized

* So you need to open another ktd --shell

* Check the log:
  tail -n 4 /var/log/koha/kohadev/plack-error.log
    Starman::Server (type Net::Server::PreFork) starting! pid(27638)
    Binding to UNIX socket file "/var/run/koha/kohadev/plack.sock"
    Starman: Accepting connections at
unix://localhost:/var/run/koha/kohadev/plack.sock/

* Update a code file
  touch Koha/Biblios.pm

* in the other shell (where plack is running) you should see:
  -- /kohadevbox/koha/Koha/Biblios.pm updated.
  Killing the existing server
  Successfully killed! Restarting the new server process.

* Yay!

* If you want to still stop/restart plack manually, you can hit CTRL-C
  in the shell were you started plack to stop the process.

Signed-off-by: David Cook <dcook at prosentient.com.au>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list