Commit 84f7f6d4 authored by Chris McDonough's avatar Chris McDonough

Remove out of date INSTALL.txt and unused ZService.py.

parent 5933c548
ZServer Installation
--------------------
Requirements
ZServer comes with Zope 2. Though ZServer can be used with earlier
versions of Zope, this is not supported and not covered by this
document.
Configuration
To run ZServer you simply execute the z2.py start script which is
located in your Zope directory. You can pass commandline arguments
to the start script in order to run Zope with different options. In
order to see a list of options use the '-h' help option.
Here's an example of use::
$ python2.1 z2.py -w 8888 -f "" -p "" -m "" &
This example starts Zope using a web server on port 8888. It does
not start and FTP server, or a PCGI server, or a Monitor server. It
also starts the server running in the backaground.
Shell scripts and batch files
You may also wish to create a shell script (or batch file under
win32) to set environment variables (such as ZOPE_DEBUG_MODE and
PYTHONHOME) and run the start script.
Here's an example shell script for a binary Zope release::
ZOPE_DEBUG_MODE=1
export ZOPE_DEBUG_MODE
PYTHONHOME=/home/Zope
export PYTHONHOME
/home/Zope/bin/python /home/Zope/z2.py -w 9673 &
Note: If ZServer fails because it can't find some standard Python
libaries there's a good bet that you need to set the PYTHONHOME as
shown above.
Here's an example batch file::
set ZOPE_DEBUG_MODE=1
"\Program Files\Zope\bin\python" "\Program Files\Zope\z2.py -w
8888 -f 8021"
Now you're ready to go.
Starting ZServer
To start ZServer run the start script::
$ python2.1 z2.py
To stop the server type 'control-c'.
Note: If you've created a shell script or batch file to run ZServer
use that instead.
You should see some Medusa information come up on the screen as Zope
starts.
A log file will be written to the 'var' directory, named
'Z2.log' by default.
Using ZServer
Once you start ZServer is will publish Zope (or any Python module)
on HTTP and/or FTP. To access Zope via HTTP point your browser at
the server like so::
http://www.example.com:9673/
This assumes that you have chosen to put HTTP on port 9673 and that
you are publishing a module named whose URL prefix is set to ''.
Note: to publish Zope normally you publish the 'lib/python/Zope.py'
module.
To access Zope via FTP you need to FTP to it at the port you set FTP
to run on. For example::
ftp www.example.com 9221
This opens a FTP session to your machine on port 9221, ZServer's
default FTP port. When you are prompted to log in you should supply
a Zope username and password. (Probably you should use an account
with the 'Manager' role, unless you have configured Zope to allow
FTP access to the 'Anonymous' role.) You can also enter 'anonymous'
and any password for anonymous FTP access. Once you have logged in
you can start issuing normal FTP commands.
Right now ZServer supports most basic FTP commands.
Note: When you log in your working directory is set to '/'. If you
do not have FTP permissions in this directory, you will need to 'cd'
to a directory where you have permissions before you can do
anything. See above for more information about logging into FTP.
Advanced Usage: zdaemon.py and the Zope NT service.
One problem you may notice with ZServer is that once the server is
shutdown, either through the web management interface, or by some
other means, it will not automatically be restarted.
On Unix you can use zdeamon.py to keep Zope running. Specifying
the '-Z' switch when starting Zope runs zdaemon.py. Zdeamon
will restart Zope when it Zope is restarted through the web, and in
case of an unexpected error.
On NT, use the Zope service for the same functionality. See ZServer.py
for more information on running ZServer as a service.
Where to go from here
Check out the README.txt file. It contains information on what
ZServer can do, how it works and and what you can do if you run into
problems.
And don't forget to have fun!
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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
#
##############################################################################
"""
ZServer as a NT service.
The serice starts up and monitors a ZServer process.
Features:
* When you start the service it starts ZServer
* When you stop the serivice it stops ZServer
* It monitors ZServer and restarts it if it exits abnormally
* If ZServer is shutdown from the web, the service stops.
* If ZServer cannot be restarted, the service stops.
Usage:
Installation
The ZServer service should be installed by the Zope Windows
installer. You can manually install, uninstall the service from
the commandline.
ZService.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
ZServer.py
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 ZServer.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.
Registry Settings
You can change how the service starts ZServer by editing a registry
key.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
<Service Name>\Parameters\start
The value of this key is the command which the service uses to
start ZServer. For example:
"C:\Program Files\Zope\bin\python.exe"
"C:\Program Files\Zope\z2.py" -w 8888
TODO:
* Integrate it into the Windows installer.
* Add ZLOG logging in addition to event log logging.
* Make it easier to run multiple Zope services with one Zope install
This script does for NT the same sort of thing zdaemon.py does for UNIX.
Requires Python win32api extensions.
"""
import sys, os, time, imp
# Some fancy path footwork is required here because we
# may be run from python.exe or lib/win32/PythonService.exe
home=os.path.split(os.path.split(sys.executable)[0])[0]
if sys.executable[-10:]!='python.exe':
home=os.path.split(home)[0]
home=os.path.split(home)[0]
sys.path.append(os.path.join(home, 'bin'))
sys.path.append(os.path.join(home, 'ZServer'))
sys.path.append(os.path.join(home, 'bin', 'lib', 'win32'))
sys.path.append(os.path.join(home, 'bin', 'lib', 'win32', 'lib'))
# pythoncom and pywintypes are special, and require these hacks when
# we dont have a standard Python installation around.
import win32api
def magic_import(modulename, filename):
# by Mark Hammond
try:
# See if it does import first!
return __import__(modulename)
except ImportError:
pass
# win32 can find the DLL name.
h = win32api.LoadLibrary(filename)
found = win32api.GetModuleFileName(h)
# Python can load the module
mod = imp.load_module(modulename, None, found, ('.dll', 'rb', imp.C_EXTENSION))
# inject it into the global module list.
sys.modules[modulename] = mod
# And finally inject it into the namespace.
globals()[modulename] = mod
win32api.FreeLibrary(h)
magic_import('pywintypes','pywintypes21.dll')
import win32serviceutil, win32service, win32event, win32process
try: import servicemanager
except: pass
class ZServerService(win32serviceutil.ServiceFramework):
# Some trickery to determine the service name. The WISE
# installer will write an svcname.txt to the ZServer dir
# that we can use to figure out our service name.
path=os.path.join(home, 'ZServer', 'svcname.txt')
file=open(path, 'r')
_svc_name_=file.readline().strip()
file.close()
_svc_display_name_ = "Zope (%s)" % _svc_name_
restart_min_time=5 # if ZServer restarts before this many
# seconds then we have a problem, and
# need to stop the service.
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
def SvcDoRun(self):
self.start_zserver()
while 1:
rc=win32event.WaitForMultipleObjects(
(self.hWaitStop, self.hZServer), 0, win32event.INFINITE)
if rc - win32event.WAIT_OBJECT_0 == 0:
break
else:
self.restart_zserver()
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING, 5000)
def SvcStop(self):
servicemanager.LogInfoMsg('Stopping Zope.')
try:
self.stop_zserver()
except:
pass
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
def start_zserver(self):
sc=self.get_start_command()
result=win32process.CreateProcess(None, self.get_start_command(),
None, None, 0, 0, None, None, win32process.STARTUPINFO())
self.hZServer=result[0]
self.last_start_time=time.time()
servicemanager.LogInfoMsg('Starting Zope.')
def stop_zserver(self):
win32process.TerminateProcess(self.hZServer,0)
def restart_zserver(self):
if time.time() - self.last_start_time < self.restart_min_time:
servicemanager.LogErrorMsg('Zope died and could not be restarted.')
self.SvcStop()
code=win32process.GetExitCodeProcess(self.hZServer)
if code == 0:
# Exited with a normal status code,
# assume that shutdown is intentional.
self.SvcStop()
else:
servicemanager.LogWarningMsg('Restarting Zope.')
self.start_zserver()
def get_start_command(self):
return win32serviceutil.GetServiceCustomOption(self,'start')
def set_start_command(value):
"sets the ZServer start command if the start command is not already set"
current=win32serviceutil.GetServiceCustomOption(ZServerService,
'start', None)
if current is None:
win32serviceutil.SetServiceCustomOption(ZServerService,'start',value)
if __name__=='__main__':
win32serviceutil.HandleCommandLine(ZServerService)
if 'install' in sys.argv:
command='"%s" "%s" -S' % (sys.executable, os.path.join(home,'z2.py'))
set_start_command(command)
print "Setting ZServer start command to:", command
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment