summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-06-05 23:07:13 -0400
committerRob Crittenden <rcritten@redhat.com>2008-06-09 22:12:10 -0400
commit108f4a7a28d67d68fa6e10585e9c11c25cbe6ee0 (patch)
tree1788fafa4553d58bfc3c87dc39d5a16fbd9d9046
parent71b03a174ae7f7b330f03768ed14431f6c3ab3dc (diff)
downloadfreeipa-108f4a7a28d67d68fa6e10585e9c11c25cbe6ee0.tar.gz
freeipa-108f4a7a28d67d68fa6e10585e9c11c25cbe6ee0.tar.xz
freeipa-108f4a7a28d67d68fa6e10585e9c11c25cbe6ee0.zip
Add our own SIGTERM handler so we can do clean shutdowns.
Also fix foreground mode. 450211
-rw-r--r--ipa-server/ipa-gui/ipa_webgui15
1 files changed, 13 insertions, 2 deletions
diff --git a/ipa-server/ipa-gui/ipa_webgui b/ipa-server/ipa-gui/ipa_webgui
index 5df57895..677fc9a5 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