supervisord: allow to start with --nodaemon.

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