[Checkins] SVN: zc.zodbrecipes/trunk/zc/zodbrecipes/ Make logrotate config generation optional.

Chris Withers chris at simplistix.co.uk
Fri Nov 20 13:53:47 EST 2009


Log message for revision 105921:
  Make logrotate config generation optional.

Changed:
  U   zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py
  U   zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt

-=-
Modified: zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py
===================================================================
--- zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py	2009-11-20 18:31:30 UTC (rev 105920)
+++ zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py	2009-11-20 18:53:47 UTC (rev 105921)
@@ -35,9 +35,14 @@
             options['run-directory'] = buildout[deployment]['run-directory']
             options['log-directory'] = buildout[deployment]['log-directory']
             options['etc-directory'] = buildout[deployment]['etc-directory']
-            options['logrotate'] = os.path.join(
-                buildout[deployment]['logrotate-directory'],
-                options['deployment-name'] + '-' + self.name)
+            logrotate = options.get('logrotate',
+                                    buildout[deployment].get('logrotate',''))
+            if logrotate.lower()=='false':
+                options['logrotate'] = ''
+            else:
+                options['logrotate'] = os.path.join(
+                    buildout[deployment]['logrotate-directory'],
+                    options['deployment-name'] + '-' + self.name)
             options['crontab-directory'] = buildout[
                 deployment]['crontab-directory']
             options['user'] = buildout[deployment]['user']
@@ -90,17 +95,21 @@
                                        self.name+'-zdaemon.sock')
             rc = options['deployment-name'] + '-' + self.name
 
+            options.created(
+                zeo_conf_path,
+                zdaemon_conf_path,
+                os.path.join(options['rc-directory'], rc),
+                )
+            
             logrotate = options['logrotate']
-            open(logrotate, 'w').write(logrotate_template % dict(
-                logfile=event_log_path,
-                rc=os.path.join(options['rc-directory'], rc),
-                conf=zdaemon_conf_path,
-                ))
+            if logrotate:
+                open(logrotate, 'w').write(logrotate_template % dict(
+                    logfile=event_log_path,
+                    rc=os.path.join(options['rc-directory'], rc),
+                    conf=zdaemon_conf_path,
+                    ))
+                options.created(logrotate)
 
-            options.created(zeo_conf_path, zdaemon_conf_path, logrotate,
-                            os.path.join(options['rc-directory'], rc),
-                            )
-
             pack = options.get('pack')
             if pack:
                 pack = pack.split()

Modified: zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt
===================================================================
--- zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt	2009-11-20 18:31:30 UTC (rev 105920)
+++ zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt	2009-11-20 18:53:47 UTC (rev 105921)
@@ -420,8 +420,11 @@
     -  server-zdaemon.conf
     -  server-zeo.conf
 
-In additional we'll get a logrotate configuration file:
+Log rotation
+============
 
+If a deployment is used, we'll also get a logrotate configuration file:
+
     >>> cat('rotate', 'demo-server')
     /sample-buildout/log/server-zeo.log {
       rotate 5
@@ -457,6 +460,101 @@
 their part names.  Also note that the deployment user is set in the
 zdaemon configuration.
 
+If you want to manage your own log rotation, you can place "logrotate = false" 
+in your deployment section to prevent the logrotate config being generated:
+
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... parts = zodb server
+    ... 
+    ... [zodb]
+    ... recipe = zc.recipe.egg:script
+    ... eggs = ZODB3
+    ... 
+    ... [server]
+    ... recipe = zc.zodbrecipes:server
+    ... zeo.conf = 
+    ...    <zeo>
+    ...       address 8100
+    ...       monitor-address 8101
+    ...       transaction-timeout 300
+    ...    </zeo>
+    ...    %%import foo
+    ...    <foo main>
+    ...       path /databases/Data.fs
+    ...    </foo>
+    ... deployment = demo
+    ...
+    ... [demo]
+    ... logrotate = false
+    ... crontab-directory = %(cron)s
+    ... etc-directory = %(etc)s
+    ... log-directory = %(log)s
+    ... logrotate-directory = %(rotate)s
+    ... rc-directory = %(rc)s
+    ... run-directory = %(run)s
+    ... user = bob
+    ... ''' % globals())
+
+    >>> print system(buildout),
+    Uninstalling server.
+    Updating zodb.
+    Installing server.
+    Generated script '/sample-buildout/rc/demo-server'.
+
+The logrotate config is not there, but the rc script still is:
+
+    >>> ls('rotate')
+    >>> ls('rc')
+    -  demo-server
+
+If it's more convenient, this can be placed in the [server] section instead:
+
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... parts = zodb server
+    ... 
+    ... [zodb]
+    ... recipe = zc.recipe.egg:script
+    ... eggs = ZODB3
+    ... 
+    ... [server]
+    ... recipe = zc.zodbrecipes:server
+    ... zeo.conf = 
+    ...    <zeo>
+    ...       address 8100
+    ...       monitor-address 8101
+    ...       transaction-timeout 300
+    ...    </zeo>
+    ...    %%import foo
+    ...    <foo main>
+    ...       path /databases/Data.fs
+    ...    </foo>
+    ... deployment = demo
+    ... logrotate = false
+    ...
+    ... [demo]
+    ... crontab-directory = %(cron)s
+    ... etc-directory = %(etc)s
+    ... log-directory = %(log)s
+    ... logrotate-directory = %(rotate)s
+    ... rc-directory = %(rc)s
+    ... run-directory = %(run)s
+    ... user = bob
+    ... ''' % globals())
+
+    >>> print system(buildout),
+    Updating zodb.
+    Updating server.
+
+The logrotate config is not there, but the rc script still is:
+
+    >>> ls('rotate')
+    >>> ls('rc')
+    -  demo-server
+
 Packing cron job
 ================
 



More information about the checkins mailing list