[Zope-Checkins] SVN: Zope/branches/2.12/src/ - Fix #443005 by using the pid from the pidfile rather than that of runzope.exe
Chris Withers
chris at simplistix.co.uk
Mon Oct 5 19:10:09 EDT 2009
Log message for revision 104815:
- Fix #443005 by using the pid from the pidfile rather than that of runzope.exe
- correct capitalisation of "command" reg value name, not that it matters ;-)
- add a windebug command to help when debugging windows service behaviour
- refactor do_start: nt_svcutils.service.Service sets ZMANAGED, so its not needed on Windows.
Changed:
U Zope/branches/2.12/src/Zope2/Startup/zopectl.py
U Zope/branches/2.12/src/nt_svcutils/service.py
-=-
Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 22:37:17 UTC (rev 104814)
+++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 23:10:09 UTC (rev 104815)
@@ -212,6 +212,11 @@
args = [opt, svalue]
return args
+ def do_start(self, arg):
+ # signal to Zope that it is being managed
+ # (to indicate it's web-restartable)
+ os.putenv('ZMANAGED', '1')
+
## START OF WINDOWS ONLY STUFF
if WIN:
@@ -225,6 +230,7 @@
self.zd_status = None
return
+ do_start = do_windows('start')
do_stop = do_windows('stop')
do_restart = do_windows('restart')
@@ -242,6 +248,11 @@
self.options.configfile
)
InstanceClass.setReg('command',command)
+
+ # This is unfortunately needed because runzope.exe is a setuptools
+ # generated .exe that spawns off a sub process, so pid would give us
+ # the wrong event name.
+ InstanceClass.setReg('pid_filename',self.options.configroot.pid_filename)
def help_install(self):
print "install -- Installs Zope as a Windows service."
@@ -251,17 +262,13 @@
def help_remove(self):
print "remove -- Removes the Zope Windows service."
+ do_windebug = do_windows('debug')
+
+ def help_windebug(self):
+ print "windebug -- Runs the Zope Windows service in the foreground, in debug mode."
+
## END OF WINDOWS ONLY STUFF
- def do_start(self, arg):
- # signal to Zope that it is being managed
- # (to indicate it's web-restartable)
- os.putenv('ZMANAGED', '1')
- if WIN:
- do_windows('start')(self,arg)
- else:
- ZDCmd.do_start(self, arg)
-
def get_startup_cmd(self, python, more):
cmdline = ( '%s -c "from Zope2 import configure;'
'configure(%r);' %
Modified: Zope/branches/2.12/src/nt_svcutils/service.py
===================================================================
--- Zope/branches/2.12/src/nt_svcutils/service.py 2009-10-05 22:37:17 UTC (rev 104814)
+++ Zope/branches/2.12/src/nt_svcutils/service.py 2009-10-05 23:10:09 UTC (rev 104815)
@@ -60,7 +60,7 @@
# ...and from that, we can look up the other needed bits
# from the registry:
self._svc_display_name_ = self.getReg('DisplayName')
- self._svc_command_ = self.getReg('Command',keyname='PythonClass')
+ self._svc_command_ = self.getReg('command',keyname='PythonClass')
win32serviceutil.ServiceFramework.__init__(self, args)
@@ -268,26 +268,29 @@
def stop(self,pid):
# call the method that any subclasses out there may implement:
self.onStop()
- # Stop the child process by sending signals to the special named event.
-
-
winver = sys.getwindowsversion()
+ # This is unfortunately needed because runzope.exe is a setuptools
+ # generated .exe that spawns off a sub process, so pid would give us
+ # the wrong event name.
+ child_pid = int(
+ open(self.getReg('pid_filename',keyname='PythonClass')).read()
+ )
+ # Stop the child process by sending signals to the special named event.
for sig, timeout in (
(signal.SIGINT, 30), # We give it 90 seconds to shutdown normally.
(signal.SIGTERM, 10) # If that doesn't stop things, we give it 30
# seconds to do a "fast" shutdown.
):
- event_name = "Zope-%d-%d" % (pid, sig)
+ # See the Signals.WinSignalHandler module for
+ # the source of this event name
+ event_name = "Zope-%d-%d" % (child_pid,sig)
# sys.getwindowsversion() -> major, minor, build, platform_id, ver_string
# for platform_id, 2==VER_PLATFORM_WIN32_NT
if winver[0] >= 5 and winver[3] == 2:
event_name = "Global\\" + event_name
try:
- # XXX This no longer works, see bug #443005 on Launchpad
- # This is likely because cmd in now a setuptools-generated .exe
- # Any ideas?
he = win32event.OpenEvent(win32event.EVENT_MODIFY_STATE, 0,
event_name)
except win32event.error, details:
More information about the Zope-Checkins
mailing list