Commit b4f66a21 authored by Sidnei da Silva's avatar Sidnei da Silva

- The ZEO server now records its PID to a file like the ZEO

        client. Defaults to /var/ZEO.pid, and its
        configurable in /etc/zeo.conf.
parent 73cad28f
......@@ -28,6 +28,10 @@ Zope Changes
Features added
- The ZEO server now records its PID to a file like the ZEO
client. Defaults to $INSTANCE_HOME/var/ZEO.pid, and its
configurable in $INSTANCE_HOME/etc/zeo.conf.
- PluginIndexes: the ZCatalog's "Indexes" tab now show the number of
distinct values indexed by each index instead of a mixture of indexed
objects versus number of distinct values. Indexes derived from UnIndex
......
......@@ -93,6 +93,15 @@
</description>
</key>
<key name="pid-filename" datatype="existing-dirpath"
required="no">
<description>
The full path to the file in which to write the ZEO server's Process ID
at startup. If omitted, $INSTANCE/var/ZEO.pid is used.
</description>
<metadefault>$INSTANCE/var/ZEO.pid (or $clienthome/ZEO.pid)</metadefault>
</key>
</sectiontype>
</component>
......@@ -47,6 +47,7 @@ zeo_conf_template = """\
address %(port)d
read-only false
invalidation-queue-size 100
# pid-filename $INSTANCE/var/ZEO.pid
# monitor-address PORT
# transaction-timeout SECONDS
</zeo>
......
......@@ -104,6 +104,8 @@ class ZEOOptionsMixin:
None, 'auth-database=')
self.add('auth_realm', 'zeo.authentication_realm',
None, 'auth-realm=')
self.add('pid_file', 'zeo.pid_filename',
None, 'pid-file=')
class ZEOOptions(ZDOptions, ZEOOptionsMixin):
......@@ -126,6 +128,7 @@ class ZEOServer:
self.setup_default_logging()
self.check_socket()
self.clear_socket()
self.make_pidfile()
try:
self.open_storages()
self.setup_signals()
......@@ -134,6 +137,7 @@ class ZEOServer:
finally:
self.close_storages()
self.clear_socket()
self.remove_pidfile()
def setup_default_logging(self):
if self.options.config_logger is not None:
......@@ -228,6 +232,37 @@ class ZEOServer:
# Should we restart as with SIGHUP?
log("received SIGUSR2, but it was not handled!", level=logging.WARNING)
def make_pidfile(self):
if not self.options.read_only:
pidfile = self.options.pid_file
# 'pidfile' is marked as not required.
if not pidfile:
pidfile = os.path.join(os.environ["INSTANCE_HOME"],
"var", "ZEO.pid")
try:
if os.path.exists(pidfile):
os.unlink(pidfile)
pid = os.getpid()
f = open(pidfile,'w')
f.write(`pid`)
f.close()
except IOError:
error("PID file '%s' cannot be opened.")
except AttributeError:
pass # getpid not supported. Unix/Win only
def remove_pidfile(self):
if not self.options.read_only:
pidfile = self.options.pid_file
if not pidfile:
pidfile = os.path.join(os.environ["INSTANCE_HOME"],
"var", "ZEO.pid")
try:
if os.path.exists(pidfile):
os.unlink(pidfile)
except IOError:
error("PID file '%s' could not be removed.")
def close_storages(self):
for name, storage in self.storages.items():
log("closing storage %r" % name)
......
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