[CalendarServer-changes] [5357] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 19 11:42:11 PDT 2010
Revision: 5357
http://trac.macosforge.org/projects/calendarserver/changeset/5357
Author: sagen at apple.com
Date: 2010-03-19 11:42:10 -0700 (Fri, 19 Mar 2010)
Log Message:
-----------
Error log now supports size-based rotation, and server now actually honors the ErrorLogFile plist value. Launchd now no longer configured to send calendar server's output to /var/log/caldavd/error.log; it's now calendar server's responsibility.
Modified Paths:
--------------
CalendarServer/trunk/bin/caldavd
CalendarServer/trunk/calendarserver/provision/test/test_root.py
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/calendarserver/tap/test/test_caldav.py
CalendarServer/trunk/contrib/launchd/addressbookserver.plist
CalendarServer/trunk/contrib/launchd/calendarserver.plist
CalendarServer/trunk/doc/caldavd.8
CalendarServer/trunk/support/build.sh
CalendarServer/trunk/twistedcaldav/stdconfig.py
Modified: CalendarServer/trunk/bin/caldavd
===================================================================
--- CalendarServer/trunk/bin/caldavd 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/bin/caldavd 2010-03-19 18:42:10 UTC (rev 5357)
@@ -21,6 +21,7 @@
#PYTHONPATH
daemonize="";
+errorlogenabled="";
username="";
groupname="";
configfile="";
@@ -85,6 +86,7 @@
echo "Options:";
echo " -h Print this help and exit";
echo " -X Do not daemonize";
+ echo " -L Do not log errors to file; instead use stdout";
echo " -u User name to run as";
echo " -g Group name to run as";
echo " -f Configuration file to read";
@@ -97,11 +99,12 @@
exit 64;
}
-while getopts 'hXu:g:f:T:P:t:p:R:' option; do
+while getopts 'hXLu:g:f:T:P:t:p:R:' option; do
case "${option}" in
'?') usage; ;;
'h') usage -; exit 0; ;;
'X') daemonize="-n"; ;;
+ 'L') errorlogenabled="-o ErrorLogEnabled=False"; ;;
'f') configfile="-f ${OPTARG}"; ;;
'T') twistdpath="${OPTARG}"; ;;
'u') username="-u ${OPTARG}"; ;;
@@ -119,6 +122,4 @@
export PYTHONPATH
-echo exec "${python}" "${twistdpath}" "${twistd_reactor}" ${daemonize} ${username} ${groupname} "${plugin_name}" ${configfile} ${service_type} ${profile} "${child_reactor}";
-
-exec "${python}" "${twistdpath}" ${twistd_reactor} ${daemonize} ${username} ${groupname} "${plugin_name}" ${configfile} ${service_type} ${profile} ${child_reactor};
+exec "${python}" "${twistdpath}" ${twistd_reactor} ${daemonize} ${username} ${groupname} "${plugin_name}" ${configfile} ${service_type} ${errorlogenabled} ${profile} ${child_reactor};
Modified: CalendarServer/trunk/calendarserver/provision/test/test_root.py
===================================================================
--- CalendarServer/trunk/calendarserver/provision/test/test_root.py 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/calendarserver/provision/test/test_root.py 2010-03-19 18:42:10 UTC (rev 5357)
@@ -35,7 +35,6 @@
from twistedcaldav.directory.test.test_xmlfile import xmlFile, augmentsFile
from calendarserver.provision.root import RootResource
-from twistedcaldav.config import config
from twistedcaldav.directory import augment
class FakeCheckSACL(object):
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2010-03-19 18:42:10 UTC (rev 5357)
@@ -35,7 +35,8 @@
from zope.interface import implements
-from twisted.python.log import FileLogObserver
+from twisted.python.log import FileLogObserver, ILogObserver
+from twisted.python.logfile import LogFile
from twisted.python.usage import Options, UsageError
from twisted.python.reflect import namedClass
from twisted.plugin import IPlugin
@@ -106,9 +107,30 @@
def __init__(self, logObserver):
self.logger = logObserver
-class CalDAVService (MultiService):
+
+class ErrorLoggingMultiService(MultiService):
+ """ Registers a rotating file logger for error logging, iff
+ config.ErrorLogEnabled is True. """
+
+ def setServiceParent(self, app):
+ MultiService.setServiceParent(self, app)
+
+ if config.ErrorLogEnabled:
+ errorLogFile = LogFile.fromFullPath(
+ config.ErrorLogFile,
+ rotateLength=config.ErrorLogRotateMB * 1024 * 1024,
+ maxRotatedFiles=config.ErrorLogMaxRotatedFiles
+ )
+ errorLogObserver = FileLogObserver(errorLogFile).emit
+
+ # Registering ILogObserver with the Application object
+ # gets our observer picked up within AppLogger.start( )
+ app.setComponent(ILogObserver, errorLogObserver)
+
+
+class CalDAVService (ErrorLoggingMultiService):
def __init__(self, logObserver):
- self.logObserver = logObserver
+ self.logObserver = logObserver # accesslog observer
MultiService.__init__(self)
def privilegedStartService(self):
@@ -240,14 +262,6 @@
if gid and gid != os.getgid():
gottaBeRoot()
- #
- # Ignore the logfile parameter if not daemonized and log to stdout.
- #
- if self.parent["nodaemon"]:
- self.parent["logfile"] = None
- else:
- self.parent["logfile"] = config.ErrorLogFile
-
self.parent["pidfile"] = config.PIDFile
@@ -540,7 +554,7 @@
config.AccessLogFile,
)
- self.log_info("Configuring log observer: %s" % (logObserver,))
+ self.log_info("Configuring access log observer: %s" % (logObserver,))
service = CalDAVService(logObserver)
@@ -690,7 +704,7 @@
makeService_Single = makeService_Slave
def makeService_Combined(self, options):
- s = MultiService()
+ s = ErrorLoggingMultiService()
# Make sure no old socket files are lying around.
self.deleteStaleSocketFiles()
@@ -988,6 +1002,7 @@
"-o", "BindAddresses=%s" % (",".join(self.interfaces),),
"-o", "PIDFile=None",
"-o", "ErrorLogFile=None",
+ "-o", "ErrorLogEnabled=False",
"-o", "LogID=%s" % (self.id,),
"-o", "MultiProcess/ProcessCount=%d"
% (config.MultiProcess.ProcessCount,),
Modified: CalendarServer/trunk/calendarserver/tap/test/test_caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/test/test_caldav.py 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/calendarserver/tap/test/test_caldav.py 2010-03-19 18:42:10 UTC (rev 5357)
@@ -136,13 +136,11 @@
argv = [
"-f", myConfigFile,
- "-o", "ErrorLogFile=/dev/null",
"-o", "PIDFile=/dev/null",
]
self.config.parseOptions(argv)
- self.assertEquals(self.config.parent["logfile"], "/dev/null")
self.assertEquals(self.config.parent["pidfile"], "/dev/null")
def test_specifyConfigFile(self):
Modified: CalendarServer/trunk/contrib/launchd/addressbookserver.plist
===================================================================
--- CalendarServer/trunk/contrib/launchd/addressbookserver.plist 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/contrib/launchd/addressbookserver.plist 2010-03-19 18:42:10 UTC (rev 5357)
@@ -42,13 +42,7 @@
<key>ThrottleInterval</key>
<integer>60</integer>
-
- <key>StandardOutPath</key>
- <string>/var/log/carddavd/error.log</string>
- <key>StandardErrorPath</key>
- <string>/var/log/carddavd/error.log</string>
-
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
Modified: CalendarServer/trunk/contrib/launchd/calendarserver.plist
===================================================================
--- CalendarServer/trunk/contrib/launchd/calendarserver.plist 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/contrib/launchd/calendarserver.plist 2010-03-19 18:42:10 UTC (rev 5357)
@@ -42,13 +42,7 @@
<key>ThrottleInterval</key>
<integer>60</integer>
-
- <key>StandardOutPath</key>
- <string>/var/log/caldavd/error.log</string>
- <key>StandardErrorPath</key>
- <string>/var/log/caldavd/error.log</string>
-
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
Modified: CalendarServer/trunk/doc/caldavd.8
===================================================================
--- CalendarServer/trunk/doc/caldavd.8 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/doc/caldavd.8 2010-03-19 18:42:10 UTC (rev 5357)
@@ -23,6 +23,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl hX
+.Op Fl hL
.Op Fl u Ar username
.Op Fl g Ar groupname
.Op Fl T Ar twistd
@@ -41,6 +42,8 @@
Displays usage information
.It Fl X
Starts the server but does not daemonize it.
+.It Fl L
+Sends error logging output to stdout rather than the file specified in caldavd.plist.
.It Fl u Ar username
Drops privileges to the given username.
.It Fl g Ar groupname
Modified: CalendarServer/trunk/support/build.sh
===================================================================
--- CalendarServer/trunk/support/build.sh 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/support/build.sh 2010-03-19 18:42:10 UTC (rev 5357)
@@ -51,7 +51,7 @@
disable_setup="false";
print_path="false";
install="";
- daemonize="-X";
+ daemonize="-X -L";
kill="false";
restart="false";
plugin_name="caldav";
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2010-03-19 18:27:38 UTC (rev 5356)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2010-03-19 18:42:10 UTC (rev 5357)
@@ -271,6 +271,9 @@
#
"AccessLogFile" : "access.log", # Apache-style access log
"ErrorLogFile" : "error.log", # Server activity log
+ "ErrorLogEnabled" : True, # True = use log file, False = stdout
+ "ErrorLogRotateMB" : 10, # Rotate error log after so many megabytes
+ "ErrorLogMaxRotatedFiles" : 5, # Retain this many error log files
"PIDFile" : "caldavd.pid",
"RotateAccessLog" : False,
"EnableExtendedAccessLog": True,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100319/c76508ab/attachment-0001.html>
More information about the calendarserver-changes
mailing list