[Zope3-dev] How to shutdown Zope3 gracefully?

Benji York benji at zope.com
Tue Jul 19 15:32:32 EDT 2005


Adam Groszer wrote:
>>>[Adam Groszer]
>>>What do you say, can there be any data loss if I use the Shutdown
>>>button? Does Zope write everything out to disc before it quits?

Zope (or rather ZODB FileStorage) writes all transactions to disk when 
they are committed.  (Baring extraordinary bugs) any committed 
transaction cannot be corrupted.

>>[Tim Peters]
>>It didn't look to me like there's any code in Zope3 now supporting
>>controlled ("graceful") shutdown, although this is the first time I
>>looked at Zope3's shutdown code and may have missed something. 
>>There's elaborate (probably _overly_ elaborate) code in Zope2 trying
>>to do controlled shutdown.

To clarify here, there is no danger of losing/corrupting already 
committed transactions in ZODB.  Any current transactions will simple be 
uncommitted.  If you want to programmatically tell Zope to stop you can 
use code like this:

     from zope.app import zapi
     from zope.app.applicationcontrol.interfaces import IServerControl
     control = zapi.getUtility(IServerControl)
     control.shutdown(0)

>>>[Adam Groszer]
>>>Or, a better question: how to stop Zope3 cleanly (and when possible
>>>quickly, for development sessions)?

>>[Tim Peters]
>>Sorry, no idea here.  Anyone else?

Control-C.

As I said above, there is no danger of corrupting data in a "stock" 
install.

There *is* the possibility of having on-going interactions with external 
systems that need some sort of shutdown (eg. relational databases, etc). 
  In that case I would recommend the Python standard library module 
"atexit".

In summary: It might be nice if Z3 closed file handles and waited for 
outstanding requests to be handled, but the current shutdown story is 
perfectly "safe".
-- 
Benji York
Senior Software Engineer
Zope Corporation


More information about the Zope3-dev mailing list