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