supervisord: allow to start with --nodaemon.

parent b05433d4
......@@ -39,9 +39,22 @@ class SupervisordCommand(ConfigCommand):
"""
command_group = 'node'
def get_parser(self, prog_name):
ap = super(SupervisordCommand, self).get_parser(prog_name)
ap.add_argument('-n', '--nodaemon', action='store_true',
help='Do not daemonize supervisord')
return ap
def take_action(self, args):
configp = self.fetch_config(args)
instance_root = configp.get('slapos', 'instance_root')
if args.nodaemon:
supervisord_additional_argument_list = ['--nodaemon']
else:
supervisord_additional_argument_list = []
launchSupervisord(socket=os.path.join(instance_root, 'supervisord.socket'),
configuration_file=os.path.join(instance_root, 'etc', 'supervisord.conf'),
logger=self.app.log)
logger=self.app.log,
supervisord_additional_argument_list=supervisord_additional_argument_list)
......@@ -47,7 +47,7 @@ def getSupervisorRPC(socket):
return getattr(server_proxy, 'supervisor')
def launchSupervisord(socket, configuration_file, logger):
def launchSupervisord(socket, configuration_file, logger, supervisord_additional_argument_list=None):
if os.path.exists(socket):
trynum = 1
while trynum < 6:
......@@ -76,13 +76,18 @@ def launchSupervisord(socket, configuration_file, logger):
logger.warning(log_message)
break
supervisord_argument_list = ['-c', configuration_file]
if supervisord_additional_argument_list is not None:
supervisord_argument_list.extend(supervisord_additional_argument_list)
logger.info("Launching supervisord with clean environment.")
# Extract python binary to prevent shebang size limit
invocation_list = ["supervisord", '-c']
invocation_list.append("import sys ; sys.path=" + str(sys.path) + " ; import "
"supervisor.supervisord ; sys.argv[1:1]=['-c','" +
configuration_file +
"'] ; supervisor.supervisord.main()")
invocation_list.append(
"import sys ; sys.path=" + str(sys.path) + " ; " +
"import supervisor.supervisord ; " +
"sys.argv[1:1]=" + str(supervisord_argument_list) + " ; " +
"supervisor.supervisord.main()")
supervisord_popen = SlapPopen(invocation_list,
env={},
executable=sys.executable,
......
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