Commit 9b5a2a88 authored by Richard Jones's avatar Richard Jones

I've fixed the various scripts etc. in the CVS so that I can now install a ZEO...

I've fixed the various scripts etc. in the CVS so that I can now install a ZEO client/server setup. The way it actually ended up working is:

- runzope.py and zopectl.py are moved to Zope/Startup/run.py and Zope/zdaemon/zopectl.py respectively
- bin/mkzopeinstance now takes a "-z/--zeo host:port" which sets up a custom_zodb.py in the new zope instance home
- bin/mkzeoinstance now overrides less, because...
- ZEO/mkzeoinst.py generates an additional script, runzeo, which is the "runner" for the ZEO server. Both it an the zeoctl script need to know about the ZOPE_HOME, so that's been added to the scripts (via the params)
- fixed setup.py so it installed ZEO/schema.xml
parent c9154033
...@@ -23,16 +23,12 @@ options (all of which have default values), create the following: ...@@ -23,16 +23,12 @@ options (all of which have default values), create the following:
<home>/etc/zeoctl.conf -- zdctl+zdrun 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/zeoctl -- start/stop script (a shim for zdctl.py) <home>/bin/zeoctl -- start/stop script (a shim for zdctl.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
would be written if it didn't exist. would be written if it didn't exist.
The script assumes that runzeo.py, zdrun.py, and zdctl.py can be found
on the shell's $PATH, and that their #! line names the right Python
interpreter. When you use the ZODB3 setup.py script to install the
ZODB3 software, this is taken care of.
""" """
# WARNING! Several templates and functions here are reused by ZRS. # WARNING! Several templates and functions here are reused by ZRS.
...@@ -45,7 +41,7 @@ import getopt ...@@ -45,7 +41,7 @@ import getopt
zeo_conf_template = """# ZEO configuration file zeo_conf_template = """# ZEO configuration file
%%define INSTANCE %(home)s %%define INSTANCE_HOME %(instance_home)s
<zeo> <zeo>
address %(port)d address %(port)d
...@@ -56,24 +52,24 @@ zeo_conf_template = """# ZEO configuration file ...@@ -56,24 +52,24 @@ zeo_conf_template = """# ZEO configuration file
</zeo> </zeo>
<filestorage 1> <filestorage 1>
path $INSTANCE/var/Data.fs path $INSTANCE_HOME/var/Data.fs
</filestorage> </filestorage>
<eventlog> <eventlog>
level info level info
<logfile> <logfile>
path $INSTANCE/log/zeo.log path $INSTANCE_HOME/log/zeo.log
</logfile> </logfile>
</eventlog> </eventlog>
""" """
runner_conf_template = """# %(package)sctl configuration file runner_conf_template = """# %(package)sctl configuration file
%%define INSTANCE %(home)s %%define INSTANCE_HOME %(instance_home)s
<runner> <runner>
program %(python)s %(server)s -C $INSTANCE/etc/%(package)s.conf program $INSTANCE_HOME/bin/runzeo
socket-name $INSTANCE/etc/%(package)s.zdsock socket-name $INSTANCE_HOME/etc/%(package)s.zdsock
daemon true daemon true
forever false forever false
backoff-limit 10 backoff-limit 10
...@@ -82,16 +78,16 @@ runner_conf_template = """# %(package)sctl configuration file ...@@ -82,16 +78,16 @@ runner_conf_template = """# %(package)sctl configuration file
default-to-interactive true default-to-interactive true
# user zope # user zope
python %(python)s python %(python)s
zdrun %(zdrun)s 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/log/%(package)s.log logfile $INSTANCE_HOME/log/%(package)s.log
</runner> </runner>
<eventlog> <eventlog>
level info level info
<logfile> <logfile>
path $INSTANCE/log/%(package)sctl.log path $INSTANCE_HOME/log/%(package)sctl.log
</logfile> </logfile>
</eventlog> </eventlog>
""" """
...@@ -107,16 +103,41 @@ zdctl_template = """#!/bin/sh ...@@ -107,16 +103,41 @@ zdctl_template = """#!/bin/sh
# chkconfig: 345 90 10 # chkconfig: 345 90 10
# description: start a %(PACKAGE)s server # description: start a %(PACKAGE)s server
INSTANCE='%(home)s' PYTHON="%(python)s"
ZOPE_HOME="%(zope_home)s"
INSTANCE_HOME="%(instance_home)s"
CONFIG_FILE="$INSTANCE_HOME/etc/%(package)sctl.conf"
PYTHONPATH="$ZOPE_HOME"
export PYTHONPATH
exec %(python)s %(zdctl)s -C "$INSTANCE/etc/%(package)sctl.conf" ${1+"$@"} ZDCTL="$ZOPE_HOME/zdaemon/zdctl.py"
exec "$PYTHON" "$ZDCTL" -C "$CONFIG_FILE" ${1+"$@"}
"""
runzeo_template = """#!/bin/sh
# %(PACKAGE)s instance start script
PYTHON="%(python)s"
ZOPE_HOME="%(zope_home)s"
INSTANCE_HOME="%(instance_home)s"
CONFIG_FILE="$INSTANCE_HOME/etc/%(package)s.conf"
PYTHONPATH="$ZOPE_HOME"
export PYTHONPATH
ZEO_RUN="$ZOPE_HOME/ZEO/runzeo.py"
exec "$PYTHON" "$ZEO_RUN" -C "$CONFIG_FILE" ${1+"$@"}
""" """
def main(): def main():
ZEOInstanceBuilder().run() ZEOInstanceBuilder().run()
print "All done." print "All done."
class ZEOInstanceBuilder: class ZEOInstanceBuilder:
def run(self): def run(self):
try: try:
...@@ -133,27 +154,36 @@ class ZEOInstanceBuilder: ...@@ -133,27 +154,36 @@ class ZEOInstanceBuilder:
if len(args) not in [1, 2]: if len(args) not in [1, 2]:
print "Usage: %s home [port]" % program print "Usage: %s home [port]" % program
sys.exit(2) sys.exit(2)
home = args[0]
if not os.path.isabs(home): instance_home = args[0]
home = os.path.abspath(home) if not os.path.isabs(instance_home):
instance_home = os.path.abspath(instance_home)
for entry in sys.path:
if os.path.exists(os.path.join(entry, 'Zope')):
zope_home = entry
break
else:
print "Can't find the Zope home (not in sys.path)"
sys.exit(2)
if args[1:]: if args[1:]:
port = int(args[1]) port = int(args[1])
else: else:
port = 9999 port = 9999
checkport(port) checkport(port)
params = self.get_params(home, port)
self.create(home, params)
def get_params(self, home, port): params = self.get_params(zope_home, instance_home, port)
self.create(instance_home, params)
def get_params(self, zope_home, instance_home, port):
return { return {
"package": "zeo", "package": "zeo",
"PACKAGE": "ZEO", "PACKAGE": "ZEO",
"home": home, "zope_home": zope_home,
"instance_home": instance_home,
"port": port, "port": port,
"python": sys.executable, "python": sys.executable,
"server": which("runzeo.py"),
"zdrun": which("zdrun.py"),
"zdctl": which("zdctl.py"),
} }
def create(self, home, params): def create(self, home, params):
...@@ -165,6 +195,7 @@ class ZEOInstanceBuilder: ...@@ -165,6 +195,7 @@ class ZEOInstanceBuilder:
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) makefile(runner_conf_template, home, "etc", "zeoctl.conf", **params)
makexfile(zdctl_template, home, "bin", "zeoctl", **params) makexfile(zdctl_template, home, "bin", "zeoctl", **params)
makexfile(runzeo_template, home, "bin", "runzeo", **params)
def checkport(port): def checkport(port):
......
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