summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl MacMillan <kmacmill@redhat.com>2007-12-12 10:10:06 -0500
committerKarl MacMillan <kmacmill@redhat.com>2007-12-12 10:10:06 -0500
commit148a55811d0e9814bc2943f3600acf17be1b844e (patch)
treedc5b2b3de95be1f2f3e279b92ff01c5e285ae5ed
parent23ffab533fde03171b023d50ba72b53d0ab8f1d7 (diff)
downloadfreeipa-148a55811d0e9814bc2943f3600acf17be1b844e.tar.gz
freeipa-148a55811d0e9814bc2943f3600acf17be1b844e.tar.xz
freeipa-148a55811d0e9814bc2943f3600acf17be1b844e.zip
Return a proper error code from ipa-webgui so that
the init script can indicate when the service fails to start.
-rw-r--r--ipa-server/ipa-gui/ipa-webgui69
1 files changed, 38 insertions, 31 deletions
diff --git a/ipa-server/ipa-gui/ipa-webgui b/ipa-server/ipa-gui/ipa-webgui
index c8e3d0589..a18c2db81 100644
--- a/ipa-server/ipa-gui/ipa-webgui
+++ b/ipa-server/ipa-gui/ipa-webgui
@@ -63,41 +63,48 @@ def daemonize():
# stderr
os.open("/dev/null", os.O_RDWR)
-# To make development easier, we detect if we are in the development
-# environment to load a different configuration and avoid becoming
-# a daemon
-devel = False
-if os.path.exists(os.path.join(os.path.dirname(__file__), "Makefile.am")):
- devel = True
-
-if not devel:
- try:
- daemonize()
- except Exception, e:
- sys.stderr.write("error becoming daemon: " + str(e))
- sys.exit(1)
+def main():
+ # To make development easier, we detect if we are in the development
+ # environment to load a different configuration and avoid becoming
+ # a daemon
+ devel = False
+ if os.path.exists(os.path.join(os.path.dirname(__file__), "Makefile.am")):
+ devel = True
+
+ if not devel:
+ try:
+ daemonize()
+ except Exception, e:
+ sys.stderr.write("error becoming daemon: " + str(e))
+ sys.exit(1)
+
+ sys.path.append("/usr/share/ipa/")
-sys.path.append("/usr/share/ipa/")
+ # this must be after sys.path is changed to work correctly
+ import pkg_resources
+ pkg_resources.require("TurboGears")
+ pkg_resources.require("ipa_gui")
-# this must be after sys.path is changed to work correctly
-import pkg_resources
-pkg_resources.require("TurboGears")
-pkg_resources.require("ipa_gui")
+ from turbogears import update_config, start_server
+ import cherrypy
+ cherrypy.lowercase_api = True
-from turbogears import update_config, start_server
-import cherrypy
-cherrypy.lowercase_api = True
+ # Load the config - look for a local file first for development
+ # and then the system config file
+ if devel:
+ update_config(configfile="dev.cfg",
+ modulename="ipagui.config")
+ else:
+ update_config(configfile="/usr/share/ipa/ipa-webgui.cfg",
+ modulename="ipagui.config.app")
-# Load the config - look for a local file first for development
-# and then the system config file
-if devel:
- update_config(configfile="dev.cfg",
- modulename="ipagui.config")
-else:
- update_config(configfile="/usr/share/ipa/ipa-webgui.cfg",
- modulename="ipagui.config.app")
+ from ipagui.controllers import Root
-from ipagui.controllers import Root
+ start_server(Root())
-start_server(Root())
+try:
+ main()
+except Exception, e:
+ print "failed to start web gui: %s" % str(e)
+ sys.exit(1)