From c0d260d642d4f192a02b834165807e7d5dcfd4d8 Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Wed, 19 Oct 2011 16:02:56 +0200 Subject: [PATCH] Simplify logrotate configuration. Force usage of what I (Romain) consider as good logrotate configuration for now. --- slapos/recipe/logrotate.py | 70 ++++++++---------------------- software/erp5/instance-kumofs.cfg | 7 +-- software/erp5/instance-mariadb.cfg | 5 --- software/erp5/snippet-backend.cfg | 2 +- software/erp5/snippet-master.cfg | 5 --- software/erp5/software.cfg | 4 +- 6 files changed, 23 insertions(+), 70 deletions(-) diff --git a/slapos/recipe/logrotate.py b/slapos/recipe/logrotate.py index ab99914f2..9bb97e59f 100644 --- a/slapos/recipe/logrotate.py +++ b/slapos/recipe/logrotate.py @@ -30,39 +30,28 @@ from slapos.recipe.librecipe import GenericBaseRecipe class Recipe(GenericBaseRecipe): - def _options(self, options): - if 'name' not in options: - options['name'] = self.name - def install(self): - path_list = [] - logrotate_backup = self.options['backup'] logrotate_d = self.options['logrotate-entries'] logrotate_conf_file = self.options['conf'] - logrotate_conf = [] - logrotate_conf.append("include %s" % logrotate_d) - logrotate_conf.append("olddir %s" % logrotate_backup) - logrotate_conf.append("dateext") - - frequency = 'daily' - if 'frequency' in self.options: - frequency = self.options['frequency'] - logrotate_conf.append(frequency) - - num_rotate = 3650 - if 'num-rotate' in self.options: - num_rotate = self.options['num-rotate'] - logrotate_conf.append("rotate %s" % num_rotate) - - logrotate_conf.append("compress") - logrotate_conf.append("compresscmd %s" % self.options['gzip-binary']) - logrotate_conf.append("compressoptions -9") - logrotate_conf.append("uncompresscmd %s" % self.options['gunzip-binary']) - - logrotate_conf_file = self.createFile(logrotate_conf_file, '\n'.join(logrotate_conf)) - logrotate_conf.append(logrotate_conf_file) + logrotate_conf = [ + 'daily', + 'dateext', + 'rotate 3650', + 'compress', + 'compresscmd %s' % self.options['gzip-binary'], + 'compressoptions -9', + 'uncompresscmd %s' % self.options['gunzip-binary'], + 'notifempty', + 'sharedscripts', + 'create', + 'include %s' % logrotate_d, + 'olddir %s' % logrotate_backup, + ] + + logrotate_conf_file = self.createFile(logrotate_conf_file, + '\n'.join(logrotate_conf)) state_file = self.options['state-file'] @@ -71,46 +60,25 @@ class Recipe(GenericBaseRecipe): 'slapos.recipe.librecipe.exceute.execute', [self.options['logrotate-binary'], '-s', state_file, logrotate_conf_file, ] ) - path_list.append(logrotate) - return path_list + return [logrotate, logrotate_conf_file] class Part(GenericBaseRecipe): - def _options(self, options): - if 'name' not in options: - options['name'] = self.name - def install(self): logrotate_d = self.options['logrotate-entries'] - part_path = os.path.join(logrotate_d, self.options['name']) - conf = [] - if 'frequency' in self.options: - conf.append(self.options['frequency']) - if 'num-rotate' in self.options: - conf.append('rotate %s' % self.options['num-rotate']) - if 'post' in self.options: conf.append("postrotate\n%s\nendscript" % self.options['post']) if 'pre' in self.options: conf.append("prerotate\n%s\nendscript" % self.options['pre']) - if self.optionIsTrue('sharedscripts', False): - conf.append("sharedscripts") - - if self.optionIsTrue('notifempty', False): - conf.append('notifempty') - - if self.optionIsTrue('create', True): - conf.append('create') - log = self.options['log'] - self.createFile(os.path.join(logrotate_d, self.options['name']), + part_path = self.createFile(os.path.join(logrotate_d, self.options['name']), "%(logfiles)s {\n%(conf)s\n}" % { 'logfiles': log, 'conf': '\n'.join(conf), diff --git a/software/erp5/instance-kumofs.cfg b/software/erp5/instance-kumofs.cfg index 69688d370..8af1a019d 100644 --- a/software/erp5/instance-kumofs.cfg +++ b/software/erp5/instance-kumofs.cfg @@ -46,14 +46,9 @@ kumo-server-binary = ${kumo:location}/bin/kumo-server [logrotate-entry-kumofs] <= logrotate recipe = slapos.cookbook:logrotate.d -name = mariadb +name = kumofs log = $${kumofs-instance:kumo-gateway-log} $${kumofs-instance:kumo-manager-log} $${kumofs-instance:kumo-server-log} -frequency = daily -rotate-num = 30 -sharedscripts = true -notifempty = true -create = true # rest of parts are candidates for some generic stuff diff --git a/software/erp5/instance-mariadb.cfg b/software/erp5/instance-mariadb.cfg index fff3d8851..2d97979bf 100644 --- a/software/erp5/instance-mariadb.cfg +++ b/software/erp5/instance-mariadb.cfg @@ -89,12 +89,7 @@ state-file = $${rootdirectory:srv}/logrotate.status recipe = slapos.cookbook:logrotate.d name = mariadb log = $${mariadb-instance:error-log} $${mariadb-instance:slow-query-log} -frequency = daily -rotate-num = 30 post = $${mariadb-instance:mysql-binary} --no-defaults -B --socket=$${mariadb-instance:socket} -e "FLUSH LOGS" -sharedscripts = true -notifempty = true -create = true [cron] recipe = slapos.cookbook:cron diff --git a/software/erp5/snippet-backend.cfg b/software/erp5/snippet-backend.cfg index 8c525ae6c..b18a7f208 100644 --- a/software/erp5/snippet-backend.cfg +++ b/software/erp5/snippet-backend.cfg @@ -25,7 +25,7 @@ wrapper = $${basedirectory:services}/apache-%(backend_name)s [logrotate-entry-apache-%(backend_name)s] <= logrotate recipe = slapos.cookbook:logrotate.d -name = zope +name = apache-%(backend_name)s log = $${apache-%(backend_name)s:error-log} $${apache-%(backend_name)s:access-log} post = ${buildout:bin-directory}/killpidfromfile $${apache-%(backend_name)s:pid-file} SIGUSR1 diff --git a/software/erp5/snippet-master.cfg b/software/erp5/snippet-master.cfg index 81f931ff0..150e2c536 100644 --- a/software/erp5/snippet-master.cfg +++ b/software/erp5/snippet-master.cfg @@ -66,11 +66,6 @@ conf = $${rootdirectory:etc}/logrotate.conf logrotate-entries = $${directory:logrotate-entries} backup = $${directory:logrotate-backup} state-file = $${rootdirectory:srv}/logrotate.status -frequency = daily -rotate-num = 3650 -sharedscripts = true -notifempty = true -create = true [zeo-instance-entry-common] recipe = slapos.cookbook:zeo diff --git a/software/erp5/software.cfg b/software/erp5/software.cfg index 44c5484b8..d74fd044b 100644 --- a/software/erp5/software.cfg +++ b/software/erp5/software.cfg @@ -23,7 +23,7 @@ unzip = true [template-mariadb] recipe = slapos.recipe.template url = ${:_profile_base_location_}/instance-mariadb.cfg -md5sum = 9c8517900877ce43af64ef6db28fc520 +md5sum = 02bac3aec28226f4e7c2398bd454e8a8 output = ${buildout:directory}/template-mariadb.cfg mode = 0644 @@ -44,7 +44,7 @@ mode = 0644 [template-kumofs] recipe = slapos.recipe.template url = ${:_profile_base_location_}/instance-kumofs.cfg -md5sum = d8a4a1976f4d22fae0668be0543438cc +md5sum = 9ba8a7f8eb67c51979b38602bb6610b8 output = ${buildout:directory}/template-kumofs.cfg mode = 0644 -- 2.30.9