Don't exit zuul-web when signals are received

One of the last things the primary thread in zuul-web does after
configuring and starting the service is to call signal.pause(). This
causes it to wait for any signal to arrive and once a signal has arrived
and been handled we stopped zuul-web and killed the process.

This is a problem because SIGUSR2 is expected to toggle preformance and
debug tooling in the process. But since we exit after signal.pause()
returns we can't do that properly.

Fix this by removing the signal.pause() loop entirely and instead wait
for the web command thread to die. This command thread is the last thing
stopped by ZuulWeb.stop() so we can join() on it to wait for a complete
stop of the ZuulWeb service.

Change-Id: I66fbb86c25479823faeded8ede9c6204846c35c1
This commit is contained in:
Clark Boylan 2020-05-01 16:15:15 -07:00
parent 02081b585b
commit b058ab447e
2 changed files with 4 additions and 7 deletions

View File

@ -105,13 +105,7 @@ class WebServer(zuul.cmd.ZuulDaemonApp):
self.log.info('Zuul Web Server starting')
self.web.start()
try:
signal.pause()
except KeyboardInterrupt:
print("Ctrl + C: asking web server to exit nicely...\n")
self.exit_handler(signal.SIGINT, None)
self.web.stop()
self.web.join()
self.log.info("Zuul Web Server stopped")
def configure_authenticators(self):

View File

@ -1248,6 +1248,9 @@ class ZuulWeb(object):
self.command_socket.stop()
self.command_thread.join()
def join(self):
self.command_thread.join()
def runCommand(self):
while self._command_running:
try: