[Zope3-checkins] SVN: Zope3/trunk/zopeskel/bin/zopeservice.py.in
Preminaryt windows service support.
Jim Fulton
jim at zope.com
Fri Jun 10 10:16:35 EDT 2005
Log message for revision 30736:
Preminaryt windows service support.
Changed:
A Zope3/trunk/zopeskel/bin/zopeservice.py.in
-=-
Added: Zope3/trunk/zopeskel/bin/zopeservice.py.in
===================================================================
--- Zope3/trunk/zopeskel/bin/zopeservice.py.in 2005-06-10 14:14:31 UTC (rev 30735)
+++ Zope3/trunk/zopeskel/bin/zopeservice.py.in 2005-06-10 14:16:34 UTC (rev 30736)
@@ -0,0 +1,109 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+"""
+A Zope Windows NT service frontend.
+
+Usage:
+
+ Installation
+
+ The Zope service should be installed by the Zope Windows
+ installer. You can manually install, uninstall the service from
+ the commandline.
+
+ zopeservice.py [options] install|update|remove|start [...]
+ |stop|restart [...]|debug [...]
+
+ Options for 'install' and 'update' commands only:
+
+ --username domain\username : The Username the service is to run
+ under
+
+ --password password : The password for the username
+
+ --startup [manual|auto|disabled] : How the service starts,
+ default = manual
+
+ Commands
+
+ install : Installs the service
+
+ update : Updates the service, use this when you change
+ the service class implementation
+
+ remove : Removes the service
+
+ start : Starts the service, this can also be done from the
+ services control panel
+
+ stop : Stops the service, this can also be done from the
+ services control panel
+
+ restart : Restarts the service
+
+ debug : Runs the service in debug mode
+
+ You can view the usage options by running ntservice.py 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
+ panel. You can set Zope to automatically start at boot time by
+ choosing 'Auto' startup by clicking the 'statup' button.
+
+ Stopping Zope
+
+ Stop Zope by clicking the 'stop' button in the services control
+ panel. You can also stop Zope through the web by going to the
+ Zope control panel and by clicking 'Shutdown'.
+
+ Event logging
+
+ Zope events are logged to the NT application event log. Use the
+ event viewer to keep track of Zope events.
+
+Note: to successfully run this script, the Zope software home needs to be on
+the PYTHONPATH.
+"""
+
+from zope.app.winservice.service import Service
+import os
+
+# these are replacements from mkzopeinstance
+PYTHON = r'<<PYTHON>>'
+PYTHONDIR = os.path.split(PYTHON)[0]
+PYTHONW = os.path.join(PYTHONDIR, 'pythonw.exe')
+PYTHONSERVICE_EXE=r'%s\Lib\site-packages\win32\pythonservice.exe' % PYTHONDIR
+SOFTWARE_HOME=r'<<SOFTWARE_HOME>>'
+INSTANCE_HOME = r'<<INSTANCE_HOME>>'
+RUNZOPE = os.path.join(INSTANCE_HOME, 'bin', 'runzope')
+
+
+class InstanceService(Service):
+ start_cmd = '"%s" "%s"' % (PYTHONW, RUNZOPE)
+ _svc_name_ = 'Zope_%s' % str(hash(INSTANCE_HOME))
+ _svc_display_name_ = 'Zope instance at %s' % INSTANCE_HOME
+ _exe_name_ = PYTHONSERVICE_EXE
+
+
+if __name__ == '__main__':
+ import win32serviceutil
+ if os.path.exists(PYTHONSERVICE_EXE):
+ # This ensures that pythonservice.exe is registered...
+ os.system('%s -register' % PYTHONSERVICE_EXE)
+ win32serviceutil.HandleCommandLine(InstanceService)
Property changes on: Zope3/trunk/zopeskel/bin/zopeservice.py.in
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
More information about the Zope3-Checkins
mailing list