[Zope3-checkins]
SVN: Zope3/trunk/src/zope/app/winservice/service.py
Port from 2.7 and 2.8 branches.
Tim Peters
tim.one at comcast.net
Mon Jun 20 17:04:25 EDT 2005
Log message for revision 30870:
Port from 2.7 and 2.8 branches.
Shut down cleanly when Windows is shutting down.
Or, rather, make that possible if SvcStop is changed:
the Zope2 service code is in much better shape than the
Zope3 service code now. The Zope3 service code makes
it impossible for a service to shut down cleanly; Mark
Hammond added new machinery to Zope2 so that services can
shut down cleanly. Zope3 is missing all that. Added a
TODO here.
Note: ZRS gets its base service code from Zope2 (not
from Zope3), so ZRS can manage to shut down cleanly
even if run with Zope3.
Changed:
U Zope3/trunk/src/zope/app/winservice/service.py
-=-
Modified: Zope3/trunk/src/zope/app/winservice/service.py
===================================================================
--- Zope3/trunk/src/zope/app/winservice/service.py 2005-06-20 20:49:44 UTC (rev 30869)
+++ Zope3/trunk/src/zope/app/winservice/service.py 2005-06-20 21:04:25 UTC (rev 30870)
@@ -62,6 +62,13 @@
def SvcStop(self):
# Before we do anything, tell the SCM we are starting the stop process.
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
+
+ # TODO: This TerminateProcess call doesn't make much sense: it's
+ # doing a hard kill _first_, never giving the process a chance to
+ # shut down cleanly. Compare to current Zope2 service code, which
+ # uses Windows events to give the process a chance to shut down
+ # cleanly, doing a hard kill only if that doesn't succeed.
+
# stop the process if necessary
try:
win32process.TerminateProcess(self.hZope, 0)
@@ -71,6 +78,11 @@
# And set my event.
win32event.SetEvent(self.hWaitStop)
+ # SvcStop only gets triggered when the user explictly stops (or restarts)
+ # the service. To shut the service down cleanly when Windows is shutting
+ # down, we also need to hook SvcShutdown.
+ SvcShutdown = SvcStop
+
def createProcess(self, cmd):
return win32process.CreateProcess(
None, cmd, None, None, 0, 0, None, None,
More information about the Zope3-Checkins
mailing list