[Zope-Checkins] CVS: Zope/skel/bin - zopeservice.py.in:1.1.2.10

Sidnei da Silva sidnei at awkly.org
Tue Apr 12 23:42:04 EDT 2005


Update of /cvs-repository/Zope/skel/bin
In directory cvs.zope.org:/tmp/cvs-serv27740/skel/bin

Modified Files:
      Tag: Zope-2_7-branch
	zopeservice.py.in 
Log Message:

Major service enhancements.  Service cleanly shuts down child, and if child
fails the tail of the process output (which generally contains a traceback)
is
written to the event log.

Minor tweaks to the Windows build 'clean' process and documentation tweaks.


=== Zope/skel/bin/zopeservice.py.in 1.1.2.9 => 1.1.2.10 ===
--- Zope/skel/bin/zopeservice.py.in:1.1.2.9	Thu Dec 16 13:08:39 2004
+++ Zope/skel/bin/zopeservice.py.in	Tue Apr 12 23:41:34 2005
@@ -38,8 +38,9 @@
 
       install : Installs the service
 
-      update : Updates the service, use this when you change
-               the service class implementation 
+      update : Updates the service.  Use this if you change any
+               configuration settings and need the service to be
+               re-registered.
 
       remove : Removes the service
 
@@ -53,13 +54,9 @@
 
       debug : Runs the service in debug mode
 
-    You can view the usage options by running ntservice.py without any
+    You can view the usage options by running this module without any
     arguments.
 
-    Note: you may have to register the Python service program first,
-
-      win32\PythonService.exe /register
-
   Starting Zope
 
     Start Zope by clicking the 'start' button in the services control
@@ -74,19 +71,17 @@
 
   Event logging
 
-    Zope events are logged to the NT application event log. Use the
-    event viewer to keep track of Zope events.
+    Service related events (such as startup, shutdown, or errors executing
+    the Zope process) are logged to the NT application event log. Use the
+    event viewer to see these events.
 
-Note: to successfully run this script, the Zope software home needs to be on
-the PYTHONPATH.
-"""
+    Zope Events are still written to the Zope event logs.
 
-import os.path
-from os.path import dirname as dn
-import sys
+"""
+import sys, os
 
 # these are replacements from mkzopeinstance
-PYTHONW = r'<<PYTHONW>>'
+PYTHON = r'<<PYTHON>>'
 SOFTWARE_HOME=r'<<SOFTWARE_HOME>>'
 INSTANCE_HOME = r'<<INSTANCE_HOME>>'
 ZOPE_HOME = r'<<ZOPE_HOME>>'
@@ -95,17 +90,35 @@
 CONFIG_FILE= os.path.join(INSTANCE_HOME, 'etc', 'zope.conf')
 PYTHONSERVICE_EXE=r'%s\bin\PythonService.exe' % ZOPE_HOME
 
-os.environ['PYTHONPATH'] = SOFTWARE_HOME
+# Setup the environment, so sub-processes see these variables
+parts = os.environ.get("PYTHONPATH", "").split(os.pathsep)
+if SOFTWARE_HOME not in parts:
+    parts = filter(None, [SOFTWARE_HOME] + parts)
+    os.environ["PYTHONPATH"] = os.pathsep.join(parts)
+os.environ["INSTANCE_HOME"] = INSTANCE_HOME
+
+# Ensure SOFTWARE_HOME is on our current sys.path so we can import the
+# nt_svcutils package.
+if SOFTWARE_HOME not in sys.path:
+    sys.path.insert(0, SOFTWARE_HOME)
 
 from nt_svcutils.service import Service
 
 servicename = 'Zope_%s' % str(hash(INSTANCE_HOME.lower()))
 
 class InstanceService(Service):
-    start_cmd = '"%s" "%s" -C "%s"' % (PYTHONW, ZOPE_RUN, CONFIG_FILE)
     _svc_name_ = servicename
     _svc_display_name_ = 'Zope instance at %s' % INSTANCE_HOME
-    _exe_name_ = PYTHONSERVICE_EXE
+    # _svc_description_ can also be set (but what to say isn't clear!)
+    # If the exe we expect is not there, let the service framework search
+    # for it.  This will be true for people running from source builds and
+    # relying on pre-installed pythonservice.exe.
+    # Note this is only used at install time, not runtime.
+    if os.path.isfile(PYTHONSERVICE_EXE):
+        _exe_name_ = PYTHONSERVICE_EXE
+
+    process_runner = PYTHON
+    process_args = '"%s" -C "%s"' % (ZOPE_RUN, CONFIG_FILE)
 
 if __name__ == '__main__':
     import win32serviceutil



More information about the Zope-Checkins mailing list