From e60f7e6bd86107df9d0f5bf1762e45623c4c88a1 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 30 Oct 2018 14:46:20 +0100 Subject: [PATCH] Adding signal handler --- lib/cr_vmware_tpl/handler.py | 11 +++++++++++ python_fb_tools | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index b78f233..12ff07e 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -18,6 +18,7 @@ import time import datetime import socket import textwrap +import signal # Third party modules import pytz @@ -34,6 +35,7 @@ from fb_tools.common import pp, to_str from fb_tools.errors import HandlerError, ExpectedHandlerError, CommandNotFoundError from fb_tools.errors import TerraformVmError, TerraformVmDefinitionError, NetworkNotExistingError from fb_tools.errors import CannotConnectVsphereError, NoDatastoreFoundError +from fb_tools.errors import InterruptError from fb_tools.handler import BaseHandler @@ -132,7 +134,16 @@ class CrTplHandler(BaseHandler): retval = 0 try: + + signal.signal(signal.SIGHUP, self.signal_handler) + signal.signal(signal.SIGINT, self.signal_handler) + signal.signal(signal.SIGABRT, self.signal_handler) + signal.signal(signal.SIGTERM, self.signal_handler) + signal.signal(signal.SIGUSR1, self.signal_handler) + signal.signal(signal.SIGUSR2, self.signal_handler) + retval = self.run() + finally: # Aufräumen ... self.cluster = None diff --git a/python_fb_tools b/python_fb_tools index 2b6f3b0..04957bb 160000 --- a/python_fb_tools +++ b/python_fb_tools @@ -1 +1 @@ -Subproject commit 2b6f3b0911761160a386a005d092cd71da7aaf71 +Subproject commit 04957bbf0e37188bcc008dd8d12ed6643cb03da7 -- 2.39.5