Commit 18ca120e authored by Fred Drake's avatar Fred Drake

Change the ZEO control process and configuration schema so that a single

configuration file can be used for both the runzeo and zeoctl scripts.
This makes it easier to keep all the configuration needed to support the
ZEO server process in a single file.
For more explanation of the changes, see
http://zope.org/Members/fdrake/WikiBlog/ZEOServerConfiguration
parent 0871e5b2
...@@ -20,11 +20,10 @@ Given an "instance home directory" <home> and some configuration ...@@ -20,11 +20,10 @@ Given an "instance home directory" <home> and some configuration
options (all of which have default values), create the following: options (all of which have default values), create the following:
<home>/etc/zeo.conf -- ZEO config file <home>/etc/zeo.conf -- ZEO config file
<home>/etc/zeoctl.conf -- zdctl+zdrun config file
<home>/var/ -- Directory for data files: Data.fs etc. <home>/var/ -- Directory for data files: Data.fs etc.
<home>/log/ -- Directory for log files: zeo.log and zeoctl.log <home>/log/ -- Directory for log files: zeo.log and zeoctl.log
<home>/bin/runzeo -- the zeo server runner <home>/bin/runzeo -- the zeo server runner
<home>/bin/zeoctl -- start/stop script (a shim for zdctl.py) <home>/bin/zeoctl -- start/stop script (a shim for zeoctl.py)
The script will not overwrite existing files; instead, it will issue a The script will not overwrite existing files; instead, it will issue a
warning if an existing file is found that differs from the file that warning if an existing file is found that differs from the file that
...@@ -39,9 +38,10 @@ import sys ...@@ -39,9 +38,10 @@ import sys
import stat import stat
import getopt import getopt
zeo_conf_template = """# ZEO configuration file zeo_conf_template = """\
# ZEO configuration file
%%define INSTANCE_HOME %(instance_home)s %%define INSTANCE %(instance_home)s
<zeo> <zeo>
address %(port)d address %(port)d
...@@ -52,52 +52,42 @@ zeo_conf_template = """# ZEO configuration file ...@@ -52,52 +52,42 @@ zeo_conf_template = """# ZEO configuration file
</zeo> </zeo>
<filestorage 1> <filestorage 1>
path $INSTANCE_HOME/var/Data.fs path $INSTANCE/var/Data.fs
</filestorage> </filestorage>
<eventlog> <eventlog>
level info level info
<logfile> <logfile>
path $INSTANCE_HOME/log/zeo.log path $INSTANCE/log/zeo.log
</logfile> </logfile>
</eventlog> </eventlog>
"""
runner_conf_template = """# %(package)sctl configuration file
%%define INSTANCE_HOME %(instance_home)s
<runner> <runner>
program $INSTANCE_HOME/bin/runzeo program $INSTANCE/bin/runzeo
socket-name $INSTANCE_HOME/etc/%(package)s.zdsock socket-name $INSTANCE/etc/%(package)s.zdsock
daemon true daemon true
forever false forever false
backoff-limit 10 backoff-limit 10
exit-codes 0, 2 exit-codes 0, 2
directory $INSTANCE_HOME directory $INSTANCE
default-to-interactive true default-to-interactive true
# user zope # user zope
python %(python)s python %(python)s
zdrun %(zope_home)s/zdaemon/zdrun.py zdrun %(zope_home)s/zdaemon/zdrun.py
# This logfile should match the one in the %(package)s.conf file. # This logfile should match the one in the %(package)s.conf file.
# It is used by zdctl's logtail command, zdrun/zdctl doesn't write it. # It is used by zdctl's logtail command, zdrun/zdctl doesn't write it.
logfile $INSTANCE_HOME/log/%(package)s.log logfile $INSTANCE/log/%(package)s.log
</runner> </runner>
<eventlog>
level info
<logfile>
path $INSTANCE_HOME/log/%(package)sctl.log
</logfile>
</eventlog>
""" """
zdctl_template = """#!/bin/sh zeoctl_template = """\
# %(PACKAGE)s instance start script #!/bin/sh
# %(PACKAGE)s instance control script
# The following two lines are for chkconfig. On Red Hat Linux (and # The following two lines are for chkconfig. On Red Hat Linux (and
# some other systems), you can copy or symlink this script into # some other systems), you can copy or symlink this script into
# /etc/rc.d/init.d/ and then run chkconfig(8), to automatically start # /etc/rc.d/init.d/ and then use chkconfig(8) to automatically start
# %(PACKAGE)s at boot time. # %(PACKAGE)s at boot time.
# chkconfig: 345 90 10 # chkconfig: 345 90 10
...@@ -105,33 +95,32 @@ zdctl_template = """#!/bin/sh ...@@ -105,33 +95,32 @@ zdctl_template = """#!/bin/sh
PYTHON="%(python)s" PYTHON="%(python)s"
ZOPE_HOME="%(zope_home)s" ZOPE_HOME="%(zope_home)s"
INSTANCE_HOME="%(instance_home)s"
CONFIG_FILE="$INSTANCE_HOME/etc/%(package)sctl.conf" CONFIG_FILE="%(instance_home)s/etc/%(package)s.conf"
PYTHONPATH="$ZOPE_HOME" PYTHONPATH="$ZOPE_HOME"
export PYTHONPATH export PYTHONPATH
ZDCTL="$ZOPE_HOME/zdaemon/zdctl.py" ZEOCTL="$ZOPE_HOME/ZEO/zeoctl.py"
exec "$PYTHON" "$ZDCTL" -C "$CONFIG_FILE" ${1+"$@"} exec "$PYTHON" "$ZEOCTL" -C "$CONFIG_FILE" ${1+"$@"}
""" """
runzeo_template = """#!/bin/sh runzeo_template = """\
#!/bin/sh
# %(PACKAGE)s instance start script # %(PACKAGE)s instance start script
PYTHON="%(python)s" PYTHON="%(python)s"
ZOPE_HOME="%(zope_home)s" ZOPE_HOME="%(zope_home)s"
INSTANCE_HOME="%(instance_home)s"
CONFIG_FILE="$INSTANCE_HOME/etc/%(package)s.conf" CONFIG_FILE="%(instance_home)s/etc/%(package)s.conf"
PYTHONPATH="$ZOPE_HOME" PYTHONPATH="$ZOPE_HOME"
export PYTHONPATH export PYTHONPATH
ZEO_RUN="$ZOPE_HOME/ZEO/runzeo.py" RUNZEO="$ZOPE_HOME/ZEO/runzeo.py"
exec "$PYTHON" "$ZEO_RUN" -C "$CONFIG_FILE" ${1+"$@"} exec "$PYTHON" "$RUNZEO" -C "$CONFIG_FILE" ${1+"$@"}
""" """
def main(): def main():
...@@ -193,8 +182,7 @@ class ZEOInstanceBuilder: ...@@ -193,8 +182,7 @@ class ZEOInstanceBuilder:
makedir(home, "log") makedir(home, "log")
makedir(home, "bin") makedir(home, "bin")
makefile(zeo_conf_template, home, "etc", "zeo.conf", **params) makefile(zeo_conf_template, home, "etc", "zeo.conf", **params)
makefile(runner_conf_template, home, "etc", "zeoctl.conf", **params) makexfile(zeoctl_template, home, "bin", "zeoctl", **params)
makexfile(zdctl_template, home, "bin", "zeoctl", **params)
makexfile(runzeo_template, home, "bin", "runzeo", **params) makexfile(runzeo_template, home, "bin", "runzeo", **params)
......
...@@ -99,9 +99,9 @@ class ZEOOptionsMixin: ...@@ -99,9 +99,9 @@ class ZEOOptionsMixin:
class ZEOOptions(ZDOptions, ZEOOptionsMixin): class ZEOOptions(ZDOptions, ZEOOptionsMixin):
logsectionname = "eventlog" logsectionname = "eventlog"
schemadir = os.path.dirname(ZEO.__file__)
def __init__(self): def __init__(self):
self.schemadir = os.path.dirname(ZEO.__file__)
ZDOptions.__init__(self) ZDOptions.__init__(self)
self.add_zeo_options() self.add_zeo_options()
self.add("storages", "storages", self.add("storages", "storages",
......
<schema> <schema>
<!-- note that zeoctl.xml is a closely related schema which should
match this schema, but should require the "runner" section -->
<description> <description>
This schema describes the configuration of the ZEO storage server This schema describes the configuration of the ZEO storage server
process. process.
...@@ -13,9 +16,14 @@ ...@@ -13,9 +16,14 @@
<import package="zLOG"/> <import package="zLOG"/>
<!-- runner control -->
<import package="zdaemon"/>
<section type="zeo" name="*" required="yes" attribute="zeo" /> <section type="zeo" name="*" required="yes" attribute="zeo" />
<section type="runner" name="*" required="no" attribute="runner" />
<multisection name="+" type="ZODB.storage" <multisection name="+" type="ZODB.storage"
attribute="storages" attribute="storages"
required="yes"> required="yes">
......
"""Wrapper script for zdctl.py that causes it to use the ZEO schema."""
import os
import ZEO
import zLOG
import zdaemon.zdctl
# Main program
def main(args=None):
options = zdaemon.zdctl.ZDCtlOptions()
options.schemadir = os.path.dirname(ZEO.__file__)
options.schemafile = "zeoctl.xml"
zdaemon.zdctl.main(args, options)
if __name__ == "__main__":
main()
<schema>
<description>
This schema describes the configuration of the ZEO storage server
controller. It differs from the schema for the storage server
only in that the "runner" section is required.
</description>
<!-- Use the storage types defined by ZODB. -->
<import package="ZODB"/>
<!-- Use the ZEO server information structure. -->
<import package="ZEO"/>
<import package="zLOG"/>
<!-- runner control -->
<import package="zdaemon"/>
<section type="zeo" name="*" required="yes" attribute="zeo" />
<section type="runner" name="*" required="yes" attribute="runner" />
<multisection name="+" type="ZODB.storage"
attribute="storages"
required="yes" />
<section name="*" type="eventlog" attribute="eventlog" required="no" />
</schema>
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