docker: don't daemonize when starting images
This patch makes the nodepool process avoid starting up as a daemon in the Docker images, as it's not meant to become a background process within a container. In order to have consistent logging like in the daemonized mode we need to add a new foreground option that runs in foreground but without debug logging. Change-Id: I77e9e6e4f94cf726336419a2b22916cc1e974e62 Co-Authored-By: Tobias Henkel <tobias.henkel@bmw.de>
This commit is contained in:
parent
6a4a8f80db
commit
6b9af280df
@ -25,7 +25,7 @@ RUN /output/install-from-bindep
|
||||
CMD ["/usr/local/bin/nodepool"]
|
||||
|
||||
FROM nodepool as nodepool-launcher
|
||||
CMD ["/usr/local/bin/nodepool-launcher"]
|
||||
CMD ["/usr/local/bin/nodepool-launcher", "-f"]
|
||||
|
||||
FROM nodepool as nodepool-builder
|
||||
CMD ["/usr/local/bin/nodepool-builder"]
|
||||
CMD ["/usr/local/bin/nodepool-builder", "-f"]
|
||||
|
@ -106,9 +106,16 @@ class NodepoolApp(object):
|
||||
return parser
|
||||
|
||||
def parse_args(self):
|
||||
args = self.parser.parse_args()
|
||||
self.logconfig = self.get_path(args.logconfig)
|
||||
return args
|
||||
self.args = self.parser.parse_args()
|
||||
self.logconfig = self.get_path(self.args.logconfig)
|
||||
|
||||
# The arguments debug and foreground both lead to nodaemon mode so
|
||||
# set nodaemon if one of them is set.
|
||||
if ((hasattr(self.args, 'debug') and self.args.debug) or
|
||||
(hasattr(self.args, 'foreground') and self.args.foreground)):
|
||||
self.args.nodaemon = True
|
||||
else:
|
||||
self.args.nodaemon = False
|
||||
|
||||
def setup_logging(self):
|
||||
if self.logconfig:
|
||||
@ -118,7 +125,8 @@ class NodepoolApp(object):
|
||||
# config, leave the config set to emit to stdout.
|
||||
if hasattr(self.args, 'nodaemon') and self.args.nodaemon:
|
||||
logging_config = logconfig.ServerLoggingConfig()
|
||||
logging_config.setDebug()
|
||||
if hasattr(self.args, 'debug') and self.args.debug:
|
||||
logging_config.setDebug()
|
||||
else:
|
||||
# Setting a server value updates the defaults to use
|
||||
# WatchedFileHandler on /var/log/nodepool/{server}-debug.log
|
||||
@ -132,7 +140,7 @@ class NodepoolApp(object):
|
||||
argv = sys.argv[1:]
|
||||
|
||||
self.parser = self.create_parser()
|
||||
self.args = self.parse_args()
|
||||
self.parse_args()
|
||||
return self._do_run()
|
||||
|
||||
def _do_run(self):
|
||||
@ -161,16 +169,19 @@ class NodepoolDaemonApp(NodepoolApp):
|
||||
default='/var/run/nodepool/%s.pid' % self.app_name)
|
||||
|
||||
parser.add_argument('-d',
|
||||
dest='nodaemon',
|
||||
dest='debug',
|
||||
action='store_true',
|
||||
help='do not run as a daemon with debug logging')
|
||||
parser.add_argument('-f',
|
||||
dest='foreground',
|
||||
action='store_true',
|
||||
help='do not run as a daemon')
|
||||
|
||||
return parser
|
||||
|
||||
def parse_args(self):
|
||||
args = super(NodepoolDaemonApp, self).parse_args()
|
||||
self.pidfile = self.get_path(args.pidfile)
|
||||
return args
|
||||
super().parse_args()
|
||||
self.pidfile = self.get_path(self.args.pidfile)
|
||||
|
||||
def _do_run(self):
|
||||
if self.args.nodaemon:
|
||||
|
@ -48,10 +48,9 @@ class NodePoolBuilderApp(nodepool.cmd.NodepoolDaemonApp):
|
||||
return parser
|
||||
|
||||
def parse_args(self):
|
||||
args = super(NodePoolBuilderApp, self).parse_args()
|
||||
self.config_file = self.get_path(args.config)
|
||||
self.secure_file = self.get_path(args.secure)
|
||||
return args
|
||||
super(NodePoolBuilderApp, self).parse_args()
|
||||
self.config_file = self.get_path(self.args.config)
|
||||
self.secure_file = self.get_path(self.args.secure)
|
||||
|
||||
def run(self):
|
||||
self.nb = builder.NodePoolBuilder(
|
||||
|
@ -42,10 +42,9 @@ class NodePoolLauncherApp(nodepool.cmd.NodepoolDaemonApp):
|
||||
return parser
|
||||
|
||||
def parse_args(self):
|
||||
args = super(NodePoolLauncherApp, self).parse_args()
|
||||
self.config_file = self.get_path(args.config)
|
||||
self.secure_file = self.get_path(args.secure)
|
||||
return args
|
||||
super().parse_args()
|
||||
self.config_file = self.get_path(self.args.config)
|
||||
self.secure_file = self.get_path(self.args.secure)
|
||||
|
||||
def exit_handler(self, signum, frame):
|
||||
self.pool.stop()
|
||||
|
Loading…
Reference in New Issue
Block a user