Commit 3e7c6fe3 authored by Xavier Thompson's avatar Xavier Thompson

SlapObject: Remove supervisor file on stop

Create the supervisord configuration file for the partition's processes
on start, and remove it on stop.
parent db98a521
...@@ -687,7 +687,6 @@ class Partition(object): ...@@ -687,7 +687,6 @@ class Partition(object):
logger=self.logger, logger=self.logger,
debug=self.buildout_debug, debug=self.buildout_debug,
timeout=self.partition_timeout) timeout=self.partition_timeout)
self.updateSupervisorConfiguration()
self.createRetentionLockDelay() self.createRetentionLockDelay()
self.instance_python = getPythonExecutableFromSoftwarePath(self.software_path) self.instance_python = getPythonExecutableFromSoftwarePath(self.software_path)
...@@ -784,6 +783,7 @@ class Partition(object): ...@@ -784,6 +783,7 @@ class Partition(object):
"""Asks supervisord to start the instance. If this instance is not """Asks supervisord to start the instance. If this instance is not
installed, we install it. installed, we install it.
""" """
self.updateSupervisorConfiguration()
partition_id = self.partition_id partition_id = self.partition_id
try: try:
with self.getSupervisorRPC() as supervisor: with self.getSupervisorRPC() as supervisor:
...@@ -799,15 +799,16 @@ class Partition(object): ...@@ -799,15 +799,16 @@ class Partition(object):
def stop(self): def stop(self):
"""Asks supervisord to stop the instance.""" """Asks supervisord to stop the instance."""
partition_id = self.partition_id partition_id = self.partition_id
filename = partition_id + '.conf'
filepath = os.path.join(
self.supervisord_partition_configuration_dir, filename)
try: try:
with self.getSupervisorRPC() as supervisor: os.unlink(filepath)
supervisor.stopProcessGroup(partition_id, False) except OSError as e:
except xmlrpclib.Fault as exc: if e.errno != errno.ENOENT:
if exc.faultString.startswith('BAD_NAME:'):
self.logger.info('Partition %s not known in supervisord, ignoring' % partition_id)
else:
raise raise
else: else:
self.updateSupervisor()
self.logger.info("Requested stop of %s..." % partition_id) self.logger.info("Requested stop of %s..." % partition_id)
def destroy(self): def destroy(self):
......
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