Discussion:
[Koha-devel] Thoughts on reloading Koha plugins
d***@prosentient.com.au
2021-05-26 00:10:32 UTC
Permalink
Hi all,



It seems to me that installing Koha plugins is easy enough. Each Starman
process will load the plugin into memory because it hasn't seen it before.



However, if you're updating/upgrading a plugin, each Starman process has
already loaded it, so it won't know that it needs to reload it. I think most
of us work around this at the moment either by restarting Plack or just
letting the Starman workers die and be replaced by new ones that use the
updated code. But that doesn't seem optimal for an environment that allows
user plugins.



That said,
https://advent.plackperl.org/2009/12/day-4-reloading-applications.html and
https://metacpan.org/pod/Module::Reload have a few points on how reloading
code in a persistent process is a good way to get bugs.



I recall Kyle saying Wordpress was his inspiration for the plugins. I'm
curious how Wordpress handles plugin upgrades.



David Cook

Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia



Office: 02 9212 0899

Online: 02 8005 0595
Arthur
2021-05-26 04:09:37 UTC
Permalink
Hi David,

From what I recall about wordpress, it doesn't use any code-caching
system. (wordpress hosters could use FastCGI though).

It's reloaded at each calls.

Arthur
Post by d***@prosentient.com.au
Hi all,
 
It seems to me that installing Koha plugins is easy enough. Each
Starman process will load the plugin into memory because it hasn’t
seen it before.
 
However, if you’re updating/upgrading a plugin, each Starman process
has already loaded it, so it won’t know that it needs to reload it. I
think most of us work around this at the moment either by restarting
Plack or just letting the Starman workers die and be replaced by new
ones that use the updated code. But that doesn’t seem optimal for an
environment that allows user plugins…
 
That said,
https://advent.plackperl.org/2009/12/day-4-reloading-applications.html
<https://advent.plackperl.org/2009/12/day-4-reloading-applications.html>
and https://metacpan.org/pod/Module::Reload
<https://metacpan.org/pod/Module::Reload> have a few points on how
reloading code in a persistent process is a good way to get bugs.
 
I recall Kyle saying Wordpress was his inspiration for the plugins.
I’m curious how Wordpress handles plugin upgrades.
 
David Cook
Software Engineer
Prosentient Systems
Suite 7.03
6a Glen St
Milsons Point NSW 2061
Australia
 
Office: 02 9212 0899
Online: 02 8005 0595
 
_______________________________________________
Koha-devel mailing list
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/
d***@prosentient.com.au
2021-05-26 05:16:58 UTC
Permalink
Hmm interesting. I see instructions on setting up Wordpress with FastCGI but
no comments about any impact that would have on plugins. Maybe they just
don't worry about it the same way most Koha folk don't worry about it hehe.



David Cook

Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia



Office: 02 9212 0899

Online: 02 8005 0595



From: Koha-devel <koha-devel-***@lists.koha-community.org> On Behalf Of
Arthur
Sent: Wednesday, 26 May 2021 2:10 PM
To: koha-***@lists.koha-community.org
Subject: Re: [Koha-devel] Thoughts on reloading Koha plugins



Hi David,

From what I recall about wordpress, it doesn't use any code-caching system.
(wordpress hosters could use FastCGI though).

It's reloaded at each calls.

Arthur

On 26/05/2021 02:10, ***@prosentient.com.au
<mailto:***@prosentient.com.au> wrote:

Hi all,



It seems to me that installing Koha plugins is easy enough. Each Starman
process will load the plugin into memory because it hasn't seen it before.



However, if you're updating/upgrading a plugin, each Starman process has
already loaded it, so it won't know that it needs to reload it. I think most
of us work around this at the moment either by restarting Plack or just
letting the Starman workers die and be replaced by new ones that use the
updated code. But that doesn't seem optimal for an environment that allows
user plugins.



That said,
https://advent.plackperl.org/2009/12/day-4-reloading-applications.html and
https://metacpan.org/pod/Module::Reload have a few points on how reloading
code in a persistent process is a good way to get bugs.



I recall Kyle saying Wordpress was his inspiration for the plugins. I'm
curious how Wordpress handles plugin upgrades.



David Cook

Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia



Office: 02 9212 0899

Online: 02 8005 0595







_______________________________________________
Koha-devel mailing list
Koha-***@lists.koha-community.org
<mailto:Koha-***@lists.koha-community.org>
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/
Galen Charlton
2021-05-26 17:59:21 UTC
Permalink
Hi,
Post by d***@prosentient.com.au
Hmm interesting. I see instructions on setting up Wordpress with FastCGI
but no comments about any impact that would have on plugins. Maybe they
just don’t worry about it the same way most Koha folk don’t worry about it
hehe.
As I recall, Zend Opcache has various settings to control if and when it
will recompile the PHP scripts in caches. Depending on what settings you
choose, in a FastCGI environment it can periodically check to see if a
script has been updated and update the cache if need be - or, if you
choose, never revalidate the cache, in which case you'd need to reload or
restart php-fpm after changing code.

Also, WordPress has code that tries to clear opcache. [1, 2]

[1]
https://developer.wordpress.org/reference/functions/wp_opcache_invalidate/
[2] https://core.trac.wordpress.org/ticket/36455

Regards,

Galen
--
Galen Charlton
Implementation and IT Manager
Equinox Open Library Initiative
***@equinoxOLI.org
https://www.equinoxOLI.org
phone: 877-OPEN-ILS (673-6457)
direct: 770-709-5581
<http://evergreen-ils.org>
d***@prosentient.com.au
2021-05-27 00:00:56 UTC
Permalink
That’s interesting, Galen.



If I recall correctly, loading libraries in PHP doesn’t load them into PHP per se but rather inserts the code into the PHP script itself. I suppose in that way maybe you could cache and invalidate individual scripts and not have to worry about “unloading modules”. I don’t think we have any equivalent in Perl though, unfortunately.



With Plack, we have Plack::App::CGIBin, which caches CGI scripts by turning them into packages, but everything is living in that Starman worker process.



I have to go into a meeting but more thinking to do here




David Cook

Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia



Office: 02 9212 0899

Online: 02 8005 0595



From: Galen Charlton <***@equinoxoli.org>
Sent: Thursday, 27 May 2021 3:59 AM
To: David Cook <***@prosentient.com.au>
Cc: Arthur <***@biblibre.com>; koha-devel <koha-***@lists.koha-community.org>
Subject: Re: [Koha-devel] Thoughts on reloading Koha plugins



Hi,



On Wed, May 26, 2021 at 1:17 AM <***@prosentient.com.au <mailto:***@prosentient.com.au> > wrote:

Hmm interesting. I see instructions on setting up Wordpress with FastCGI but no comments about any impact that would have on plugins. Maybe they just don’t worry about it the same way most Koha folk don’t worry about it hehe.



As I recall, Zend Opcache has various settings to control if and when it will recompile the PHP scripts in caches. Depending on what settings you choose, in a FastCGI environment it can periodically check to see if a script has been updated and update the cache if need be - or, if you choose, never revalidate the cache, in which case you'd need to reload or restart php-fpm after changing code.



Also, WordPress has code that tries to clear opcache. [1, 2]



[1] https://developer.wordpress.org/reference/functions/wp_opcache_invalidate/

[2] https://core.trac.wordpress.org/ticket/36455



Regards,



Galen
--
Galen Charlton
Implementation and IT Manager
Equinox Open Library Initiative
***@equinoxOLI.org <mailto:***@equinoxOLI.org>
https://www.equinoxOLI.org
phone: 877-OPEN-ILS (673-6457)
direct: 770-709-5581
Loading...