[Zope] This is completely bogus but..

Shane Hathaway shathaway@earthling.net
Thu, 11 May 2000 13:19:11 -0400


"Morten W. Petersen" wrote:
> 
> I want lots of uptime. On my Linux box, and on my Zope. Problem is, there
> are so many cool products being developed all the time, so I have to
> restart Zope all the time. Is there a (hackish?) way to update filesystem
> installed products?
> 
> This could be a good thing if we want to hotpatch a server of some sort.

I have also wanted this capability ever since I started working with
Zope.  Real-time updates of a running server can be a necessity.  Today
I did some research and discovered two ways to accomplish this goal.

1) In production environments, once ZEO is released, it will be
possible to run two Zope servers from the same data source.  Just put
an HTTP redirector in front that forwards HTTP connections to the first
Zope if it's available, the second if it's not.  When you need to
restart Zope, cause your redirector to send new connections to the
second process.  You'll have to wait for all open connections to
close.  Restart the first Zope and cause the redirector to send new
connections to the first again.  Then you can restart the second
server.  This setup would actually improve Zope's stability.  However,
I'm not sure that such a redirector currently exists, given the need to
reconfigure without restarting.

2) Using the monitor interface, it is indeed possible to reload code in
real time.  However, odd bugs may creep up in the process, so do this
in development mode only.  Execute the following, translating the
commands to your platform appropriately:

	cd ZServer/medusa
	python monitor_client.py localhost 8090

Enter the Zope superuser password.  If I recall correctly, in order for
monitor_client to validate your password, it must be stored in
cleartext format in <zope>/access.  Another reason not to do this on
production servers!

	from Products.<yourproduct> import <yourmodulename>

then at any time you can execute:

	reload(<yourmodulename>)

As an example, I might use:

	from Products.PythonMethod import PythonMethod
	reload(PythonMethod)

Now here's the part that's much less obvious.  Zope already provides a
way to clear almost all objects from the cache so that the new version
of your classes can be instantiated, but if you use a timeout value
below 3 seconds, it doesn't work!

Go to the Control Panel, Database Management, Flush cache.  Enter "3"
in the text box by the "minimize" button and press "minimize".  Any
object that hasn't been accessed in the last 3 seconds will be cleared
from the cache, forcing nearly all objects to be loaded again from
ZODB, thus making use of the new revision to your product.

This could all be automated.  It would work for most products.  Would a
product that implements an imperfect "reload" function interest the
Zope community?  SPEAK UP!

Shane @ digicool.com