Add foreground option

The current options stated as 'do not run as a daemon' is actually
'run in debug mode in foreground'. When running in container we
actually want an option for running normally in foreground. Thus add a
new option -f for foreground operations and change the docker imaged
to use this accordingly.

Change-Id: I16173a73dbfb79dc2c2b05c2002ac41e20a48225
This commit is contained in:
Tobias Henkel 2019-02-07 22:17:48 +01:00
parent d48be299ab
commit a13ec193c8
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
3 changed files with 21 additions and 12 deletions

View File

@ -60,16 +60,16 @@ COPY --from=builder /usr/local/lib/zuul/ /usr/local/lib/zuul
COPY --from=builder /tmp/openshift-install/kubectl /usr/local/bin/kubectl
COPY --from=builder /tmp/openshift-install/oc /usr/local/bin/oc
CMD ["/usr/local/bin/zuul-executor"]
CMD ["/usr/local/bin/zuul-executor", "-f"]
FROM zuul as zuul-fingergw
CMD ["/usr/local/bin/zuul-fingergw"]
CMD ["/usr/local/bin/zuul-fingergw", "-f"]
FROM zuul as zuul-merger
CMD ["/usr/local/bin/zuul-merger"]
CMD ["/usr/local/bin/zuul-merger", "-f"]
FROM zuul as zuul-scheduler
CMD ["/usr/local/bin/zuul-scheduler"]
CMD ["/usr/local/bin/zuul-scheduler", "-f"]
FROM zuul as zuul-web
CMD ["/usr/local/bin/zuul-web"]
CMD ["/usr/local/bin/zuul-web", "-f"]

View File

@ -51,7 +51,7 @@ services:
- https_proxy
- no_proxy=${no_proxy},gerrit
- ZUUL_MYSQL_PASSWORD=secret
command: "sh -c '/var/playbooks/wait-to-start.sh && zuul-scheduler -d'"
command: "sh -c '/var/playbooks/wait-to-start.sh && zuul-scheduler -f'"
# FIXME: The scheduler has no ansible anymore so use the executor image.
# This needs to be changes such that ansible is not required for startup.
image: zuul/zuul-scheduler
@ -60,7 +60,7 @@ services:
- "./playbooks/:/var/playbooks/:z"
- "sshkey:/var/ssh:z"
web:
command: "sh -c '/var/playbooks/wait-to-start-gearman.sh && zuul-web -d'"
command: "sh -c '/var/playbooks/wait-to-start-gearman.sh && zuul-web -f'"
depends_on:
- scheduler
- mysql
@ -79,7 +79,6 @@ services:
- https_proxy
- no_proxy=${no_proxy},gerrit,scheduler
- ZUUL_MYSQL_PASSWORD=secret
command: "zuul-executor -d"
depends_on:
- scheduler
image: zuul/zuul-executor
@ -99,7 +98,6 @@ services:
volumes:
- "nodessh:/root/.ssh:z"
launcher:
command: "nodepool-launcher -d"
depends_on:
- zk
image: zuul/nodepool-launcher

View File

@ -120,6 +120,14 @@ class ZuulApp(object):
def parseArguments(self, args=None):
parser = self.createParser()
self.args = parser.parse_args(args)
# 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
return parser
def readConfig(self):
@ -148,12 +156,13 @@ class ZuulApp(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()
else:
# Setting a server value updates the defaults to use
# WatchedFileHandler on /var/log/zuul/{server}-debug.log
# and /var/log/zuul/{server}.log
logging_config = logconfig.ServerLoggingConfig(server=section)
if hasattr(self.args, 'debug') and self.args.debug:
logging_config.setDebug()
logging_config.apply()
def configure_connections(self, source_only=False, include_drivers=None):
@ -164,8 +173,10 @@ class ZuulApp(object):
class ZuulDaemonApp(ZuulApp, metaclass=abc.ABCMeta):
def createParser(self):
parser = super(ZuulDaemonApp, self).createParser()
parser.add_argument('-d', dest='nodaemon', action='store_true',
help='do not run as a daemon')
parser.add_argument('-d', dest='debug', action='store_true',
help='run in foreground with debug log')
parser.add_argument('-f', dest='foreground', action='store_true',
help='run in foreground with info log')
return parser
def getPidFile(self):