Thoughts on reloading Koha plugins
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
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, dcook@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 <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 Koha-devel@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/
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-bounces@lists.koha-community.org> On Behalf Of Arthur Sent: Wednesday, 26 May 2021 2:10 PM To: koha-devel@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, dcook@prosentient.com.au <mailto:dcook@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-devel@lists.koha-community.org <mailto:Koha-devel@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/
Hi, On Wed, May 26, 2021 at 1:17 AM <dcook@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 gmc@equinoxOLI.org https://www.equinoxOLI.org phone: 877-OPEN-ILS (673-6457) direct: 770-709-5581 <http://evergreen-ils.org>
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 <gmc@equinoxoli.org> Sent: Thursday, 27 May 2021 3:59 AM To: David Cook <dcook@prosentient.com.au> Cc: Arthur <arthur.suzuki@biblibre.com>; koha-devel <koha-devel@lists.koha-community.org> Subject: Re: [Koha-devel] Thoughts on reloading Koha plugins Hi, On Wed, May 26, 2021 at 1:17 AM <dcook@prosentient.com.au <mailto:dcook@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 gmc@equinoxOLI.org <mailto:gmc@equinoxOLI.org> https://www.equinoxOLI.org phone: 877-OPEN-ILS (673-6457) direct: 770-709-5581
participants (3)
-
Arthur -
dcook@prosentient.com.au -
Galen Charlton