Commit b595b063 authored by Guido van Rossum's avatar Guido van Rossum

Tweak docstring.

Add socket-name to runner conf template.
Check that the port isn't in use already.
parent 0f22342c
...@@ -16,18 +16,23 @@ ...@@ -16,18 +16,23 @@
Usage: mkzeoinst.py home [port] Usage: mkzeoinst.py home [port]
Given an "instance home directory" <home> and some configuration options (all Given an "instance home directory" <home> and some configuration
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 with default values filled in <home>/etc/zeo.conf -- ZEO config file
<home>/etc/runner.conf -- ZEO config file with default values filled in <home>/etc/runner.conf -- zdctl config file
<home>/var/ -- Directory for Data.fs <home>/var/ -- Directory for data files: Data.fs etc.
<home>/log/ -- Directory for log files: zeo.log and runner.log <home>/log/ -- Directory for log files: zeo.log and runner.log
<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.
""" """
import os import os
...@@ -61,6 +66,7 @@ runner_conf_template = """# runner configuration file ...@@ -61,6 +66,7 @@ runner_conf_template = """# runner configuration file
<runner> <runner>
program %(runzeo)s -C %(home)s/etc/zeo.conf program %(runzeo)s -C %(home)s/etc/zeo.conf
socket-name %(home)s/etc/zeo.zdsock
</runner> </runner>
""" """
...@@ -83,6 +89,7 @@ def main(): ...@@ -83,6 +89,7 @@ def main():
port = int(sys.argv[2]) port = int(sys.argv[2])
else: else:
port = 9999 port = 9999
checkport(port)
makedir(home) makedir(home)
makedir(home, "etc") makedir(home, "etc")
makedir(home, "var") makedir(home, "var")
...@@ -95,6 +102,16 @@ def main(): ...@@ -95,6 +102,16 @@ def main():
home=home, python=sys.executable, zdctl=which("zdctl.py")) home=home, python=sys.executable, zdctl=which("zdctl.py"))
print "All done." print "All done."
def checkport(port):
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind(("", port))
except socket.error:
print "A process is already listening on port %d" % port
sys.exit(2)
s.close()
def which(program): def which(program):
strpath = os.getenv("PATH") strpath = os.getenv("PATH")
binpath = strpath.split(os.pathsep) binpath = strpath.split(os.pathsep)
......
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