[Checkins] SVN: zc.zope3recipes/trunk/ - add support for contrlling (including suppressing) logrotate configuration
Fred Drake
fdrake at gmail.com
Mon Nov 22 17:34:26 EST 2010
Log message for revision 118523:
- add support for contrlling (including suppressing) logrotate configuration
- prepare for release
Changed:
U zc.zope3recipes/trunk/README.txt
U zc.zope3recipes/trunk/zc/zope3recipes/README.txt
U zc.zope3recipes/trunk/zc/zope3recipes/recipes.py
-=-
Modified: zc.zope3recipes/trunk/README.txt
===================================================================
--- zc.zope3recipes/trunk/README.txt 2010-11-22 19:09:43 UTC (rev 118522)
+++ zc.zope3recipes/trunk/README.txt 2010-11-22 22:34:25 UTC (rev 118523)
@@ -18,10 +18,11 @@
********
===================
-0.12.0 (unreleased)
+0.12.0 (2010/11/22)
===================
-- Nothing yet.
+- Provide control for generation of the logrotate configuration, include the
+ ability to suppress it when not desired.
===================
0.11.1 (2010/11/12)
Modified: zc.zope3recipes/trunk/zc/zope3recipes/README.txt
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/README.txt 2010-11-22 19:09:43 UTC (rev 118522)
+++ zc.zope3recipes/trunk/zc/zope3recipes/README.txt 2010-11-22 22:34:25 UTC (rev 118523)
@@ -1860,7 +1860,6 @@
If we provide an alternate instance name, that will be reflected in
the generated files:
-
>>> write('buildout.cfg',
... '''
... [buildout]
@@ -1960,6 +1959,131 @@
</eventlog>
+Controlling logrotate configuration
+-----------------------------------
+
+Some applications control their own log rotation policies. In these
+cases, we don't want the logrotate configuration to be generated.
+
+Setting the logrotate.conf setting affects the configuration. Setting
+it explicitly controls the content of the logrotate file for the
+instance; setting it to an empty string causes it not to be generated at
+all.
+
+Let's take a look at setting the content to a non-empty value directly:
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... develop = demo1 demo2
+ ... parts = instance
+ ...
+ ... [zope3]
+ ... location = %(zope3)s
+ ...
+ ... [myapp]
+ ... recipe = zc.zope3recipes:app
+ ... site.zcml = <include package="demo2" />
+ ... eggs = demo2
+ ...
+ ... [instance]
+ ... recipe = zc.zope3recipes:instance
+ ... application = myapp
+ ... zope.conf = ${database:zconfig}
+ ... address = 8081
+ ... deployment = myapp-deployment
+ ... logrotate.conf =
+ ... /root/var/log/myapp-run/instance-z3.log {
+ ... rotate 10
+ ... daily
+ ... postrotate
+ ... /root/etc/init.d/myapp-run-instance reopen_transcript
+ ... endscript
+ ... }
+ ...
+ ... [database]
+ ... recipe = zc.recipe.filestorage
+ ...
+ ... [myapp-deployment]
+ ... name = myapp-run
+ ... etc-directory = %(root)s/etc/myapp-run
+ ... rc-directory = %(root)s/etc/init.d
+ ... logrotate-directory = %(root)s/etc/logrotate.d
+ ... log-directory = %(root)s/var/log/myapp-run
+ ... run-directory = %(root)s/var/run/myapp-run
+ ... user = zope
+ ... ''' % globals())
+
+ >>> print system(join('bin', 'buildout')),
+ Develop: '/sample-buildout/demo1'
+ Develop: '/sample-buildout/demo2'
+ Uninstalling instance.
+ Uninstalling myapp.
+ Updating database.
+ Installing myapp.
+ Generated script '/sample-buildout/parts/myapp/runzope'.
+ Generated script '/sample-buildout/parts/myapp/debugzope'.
+ Installing instance.
+ Generated script '/root/etc/init.d/myapp-run-instance'.
+
+ >>> cat(root, 'etc', 'logrotate.d', 'myapp-run-instance')
+ /root/var/log/myapp-run/instance-z3.log {
+ rotate 10
+ daily
+ postrotate
+ /root/etc/init.d/myapp-run-instance reopen_transcript
+ endscript
+ }
+
+If we set ``logrotate.conf`` to an empty string, the file is not generated:
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... develop = demo1 demo2
+ ... parts = instance
+ ...
+ ... [zope3]
+ ... location = %(zope3)s
+ ...
+ ... [myapp]
+ ... recipe = zc.zope3recipes:app
+ ... site.zcml = <include package="demo2" />
+ ... eggs = demo2
+ ...
+ ... [instance]
+ ... recipe = zc.zope3recipes:instance
+ ... application = myapp
+ ... zope.conf = ${database:zconfig}
+ ... address = 8081
+ ... deployment = myapp-deployment
+ ... logrotate.conf =
+ ...
+ ... [database]
+ ... recipe = zc.recipe.filestorage
+ ...
+ ... [myapp-deployment]
+ ... name = myapp-run
+ ... etc-directory = %(root)s/etc/myapp-run
+ ... rc-directory = %(root)s/etc/init.d
+ ... logrotate-directory = %(root)s/etc/logrotate.d
+ ... log-directory = %(root)s/var/log/myapp-run
+ ... run-directory = %(root)s/var/run/myapp-run
+ ... user = zope
+ ... ''' % globals())
+
+ >>> print system(join('bin', 'buildout')),
+ Develop: '/sample-buildout/demo1'
+ Develop: '/sample-buildout/demo2'
+ Uninstalling instance.
+ Updating database.
+ Updating myapp.
+ Installing instance.
+ Generated script '/root/etc/init.d/myapp-run-instance'.
+
+ >>> ls(root, 'etc', 'logrotate.d')
+
+
Defining multiple similar instances
-----------------------------------
@@ -2025,8 +2149,11 @@
Develop: '/sample-buildout/demo1'
Develop: '/sample-buildout/demo2'
Uninstalling instance.
+ Uninstalling myapp.
Updating database.
- Updating myapp.
+ Installing myapp.
+ Generated script '/sample-buildout/parts/myapp/runzope'.
+ Generated script '/sample-buildout/parts/myapp/debugzope'.
Installing instance.
Generated script '/root/etc/init.d/myapp-run-instance'.
Installing instance2.
Modified: zc.zope3recipes/trunk/zc/zope3recipes/recipes.py
===================================================================
--- zc.zope3recipes/trunk/zc/zope3recipes/recipes.py 2010-11-22 19:09:43 UTC (rev 118522)
+++ zc.zope3recipes/trunk/zc/zope3recipes/recipes.py 2010-11-22 22:34:25 UTC (rev 118523)
@@ -222,8 +222,20 @@
rc)
creating = [zope_conf_path, zdaemon_conf_path,
os.path.join(options['bin-directory'], rc),
- logrotate_path,
]
+ logrotate_conf = options.get("logrotate.conf")
+ if isinstance(logrotate_conf, basestring):
+ if logrotate_conf.strip():
+ creating.append(logrotate_path)
+ else:
+ logrotate_conf = None
+ else:
+ logrotate_conf = logrotate_template % dict(
+ logfile=event_log_path,
+ rc=os.path.join(options['bin-directory'], rc),
+ conf=zdaemon_conf_path,
+ )
+ creating.append(logrotate_path)
else:
zope_conf_path = os.path.join(run_directory, 'zope.conf')
zdaemon_conf_path = os.path.join(run_directory, 'zdaemon.conf')
@@ -314,13 +326,8 @@
open(zope_conf_path, 'w').write(str(zope_conf))
open(zdaemon_conf_path, 'w').write(str(zdaemon_conf))
- if deployment:
- logrotate_event_log = logrotate_template % dict(
- logfile=event_log_path,
- rc=os.path.join(options['bin-directory'], rc),
- conf=zdaemon_conf_path,
- )
- open(logrotate_path, 'w').write(logrotate_event_log)
+ if deployment and logrotate_conf:
+ open(logrotate_path, 'w').write(logrotate_conf)
# XXX: We are using a private zc.buildout.easy_install
# function below. It would be better if self.egg had a
More information about the checkins
mailing list