summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2007-11-01 11:55:53 -0400
committerRob Crittenden <rcritten@redhat.com>2007-11-01 11:55:53 -0400
commita51dd58278126a81b1b923c528488d3580adba39 (patch)
tree79b78847d67a17ddf7e523abfdf47e91aef4ce3d
parentd9f809746bba7a818e584a5729ecc4b664efb78f (diff)
downloadfreeipa-a51dd58278126a81b1b923c528488d3580adba39.tar.gz
freeipa-a51dd58278126a81b1b923c528488d3580adba39.tar.xz
freeipa-a51dd58278126a81b1b923c528488d3580adba39.zip
TurboGears log files and log rotation
The error log is rotated weekly on Sunday. 4 backups are saved. The access log is not stored since it would be a duplicate of the Apache logs. It can be enabled if desired. Had to move the call to daemonize() in ipa-webgui so that the fork is done before TurboGears is initialized. Otherwise the log files end up getting closed.
-rw-r--r--ipa-server/ipa-gui/ipa-webgui33
-rw-r--r--ipa-server/ipa-gui/ipa-webgui.cfg12
2 files changed, 29 insertions, 16 deletions
diff --git a/ipa-server/ipa-gui/ipa-webgui b/ipa-server/ipa-gui/ipa-webgui
index f16089088..c8e3d0589 100644
--- a/ipa-server/ipa-gui/ipa-webgui
+++ b/ipa-server/ipa-gui/ipa-webgui
@@ -20,14 +20,24 @@
import os, sys
def daemonize():
- pid = os.fork()
+ # fork once so the parent can exit
+ try:
+ pid = os.fork()
+ except OSError, e:
+ raise Exception, "%s [%d]" % (e.strerror, e.errno)
+
if pid != 0:
os._exit(0)
+
# become session leader
os.setsid()
# fork again to reparent to init
- pid = os.fork()
+ try:
+ pid = os.fork()
+ except OSError, e:
+ raise Exception, "%s [%d]" % (e.strerror, e.errno)
+
if pid != 0:
os._exit(0)
@@ -60,6 +70,13 @@ 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/")
# this must be after sys.path is changed to work correctly
@@ -83,16 +100,4 @@ else:
from ipagui.controllers import Root
-if not devel:
- try:
- daemonize()
- except Exception, e:
- sys.stderr.write("error becoming daemon: " + str(e))
- sys.exit(1)
-
start_server(Root())
-
-
-
-
-
diff --git a/ipa-server/ipa-gui/ipa-webgui.cfg b/ipa-server/ipa-gui/ipa-webgui.cfg
index 7970ab86b..35b0b4f58 100644
--- a/ipa-server/ipa-gui/ipa-webgui.cfg
+++ b/ipa-server/ipa-gui/ipa-webgui.cfg
@@ -64,12 +64,20 @@ format='*(asctime)s *(name)s *(levelname)s *(message)s'
[[handlers]]
[[[debug_out]]]
-class='StreamHandler'
+# Rotate weekly on Sunday. Keep 4 backups of the log
+class='TimedRotatingFileHandler'
level='DEBUG'
-args='(sys.stdout,)'
+args="('/var/log/ipa_error.log', 'w6', 1, 4)"
formatter='full_content'
[[[access_out]]]
+# For example only if one wants to duplicate the access log in TurboGears
+# Rotate weekly on Sunday. Keep 4 backups of the log
+#class='TimedRotatingFileHandler'
+#level='INFO'
+#args="('/var/log/ipa_error.log', 'w6', 1, 4)"
+#formatter='message_only'
+# By default log access to stdout which will go to /dev/null in production
class='StreamHandler'
level='INFO'
args='(sys.stdout,)'