[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Freeipa-devel] [PATCH] fix unclean shutdown in ipa_webui



Add our own SIGTERM handler so we can do clean shutdowns.

Also fix foreground mode.

rob
>From ed975093070afa366bd00f4b9b433034469d5be1 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcritten redhat com>
Date: Thu, 5 Jun 2008 23:07:13 -0400
Subject: [PATCH] Add our own SIGTERM handler so we can do clean shutdowns.

Also fix foreground mode.

450211
---
 ipa-server/ipa-gui/ipa_webgui |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ipa-server/ipa-gui/ipa_webgui b/ipa-server/ipa-gui/ipa_webgui
index 5df5789..677fc9a 100644
--- a/ipa-server/ipa-gui/ipa_webgui
+++ b/ipa-server/ipa-gui/ipa_webgui
@@ -21,6 +21,7 @@ import os, sys, pwd, grp
 from optparse import OptionParser
 import traceback
 import logging
+import signal
 
 def usage():
     print "ipa_webgui [-f|--foreground] [-d|--debug]"
@@ -138,7 +139,7 @@ def main():
         except OSError, e:
             log.error("Could not set effective user id: %s" % e)
 
-    if devel:
+    if foreground:
         logging.basicConfig(level=loglevel,
                             format='%(asctime)s %(name)s %(levelname)s %(message)s',
                             stream=sys.stderr)
@@ -161,9 +162,19 @@ def main():
     import cherrypy
     cherrypy.lowercase_api = True
 
+    try:
+        if hasattr(signal, "SIGTERM"):
+            def SIGTERM(signum=None, frame=None):
+                cherrypy.server.stop()
+            signal.signal(signal.SIGTERM, SIGTERM)
+    except ValueError, _signal_exc:
+        if _signal_exc.args[0] != "signal only works in main thread":
+            raise
+
+
     # Shut down the logging set up here so that CherryPy logging can take
     # over. TurboGears configuration errors will not be caught.
-    if not devel:
+    if not foreground:
         logging.shutdown()
 
     # Load the config - look for a local file first for development
-- 
1.5.4

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]