[PATCH v2][Wok 0/2] Issue #118: logrotate fails

Changes: v2: Add option to change log size on wok.conf Ramon Medeiros (2): Issue #118: logrotate fails Allow wok.conf determine log file size Makefile.am | 2 -- contrib/Makefile.am | 1 - contrib/wok.spec.fedora.in | 1 - contrib/wok.spec.suse.in | 1 - contrib/wokd.logrotate.in | 9 --------- src/wok.conf.in | 3 +++ src/wok/config.py.in | 1 + src/wok/server.py | 20 ++++++++++++++------ 8 files changed, 18 insertions(+), 20 deletions(-) delete mode 100644 contrib/wokd.logrotate.in -- 2.5.5

Create file only when server is started Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- Makefile.am | 2 -- contrib/Makefile.am | 1 - contrib/wok.spec.fedora.in | 1 - contrib/wok.spec.suse.in | 1 - contrib/wokd.logrotate.in | 9 --------- src/wok/server.py | 16 +++++++++++----- 6 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 contrib/wokd.logrotate.in diff --git a/Makefile.am b/Makefile.am index 325d0c9..ac07e97 100644 --- a/Makefile.am +++ b/Makefile.am @@ -155,7 +155,6 @@ install-data-local: $(INSTALL_DATA) src/dhparams.pem $(DESTDIR)/etc/wok/dhparams.pem touch $(DESTDIR)/etc/nginx/conf.d/wok.conf mkdir -p $(DESTDIR)/etc/logrotate.d/ - $(INSTALL_DATA) $(top_srcdir)/contrib/wokd.logrotate.in $(DESTDIR)/etc/logrotate.d/wokd.in touch $(DESTDIR)/etc/logrotate.d/wokd uninstall-local: @@ -172,7 +171,6 @@ uninstall-local: $(RM) -rf $(DESTDIR)/$(localstatedir)/log/wok $(RM) -rf $(DESTDIR)/etc/wok $(RM) $(DESTDIR)/etc/nginx/conf.d/wok.conf - $(RM) $(DESTDIR)/etc/logrotate.d/wokd.in $(RM) $(DESTDIR)/etc/logrotate.d/wokd VERSION: diff --git a/contrib/Makefile.am b/contrib/Makefile.am index a82ba30..32fcfde 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -29,7 +29,6 @@ EXTRA_DIST = \ wokd-upstart.conf.debian \ wokd-upstart.conf.fedora \ make-deb.sh.in \ - wokd.logrotate.in \ $(NULL) make-deb.sh: make-deb.sh.in $(top_builddir)/config.status diff --git a/contrib/wok.spec.fedora.in b/contrib/wok.spec.fedora.in index 7715e7f..fdf3484 100644 --- a/contrib/wok.spec.fedora.in +++ b/contrib/wok.spec.fedora.in @@ -117,7 +117,6 @@ rm -rf $RPM_BUILD_ROOT %{_sysconfdir}/nginx/conf.d/wok.conf.in %{_sysconfdir}/wok/wok.conf %{_sysconfdir}/wok/ -%{_sysconfdir}/logrotate.d/wokd.in %{_sysconfdir}/logrotate.d/wokd %{_mandir}/man8/wokd.8.gz diff --git a/contrib/wok.spec.suse.in b/contrib/wok.spec.suse.in index 3d39483..70c295b 100644 --- a/contrib/wok.spec.suse.in +++ b/contrib/wok.spec.suse.in @@ -95,7 +95,6 @@ rm -rf $RPM_BUILD_ROOT %{_sysconfdir}/wok/ %{_sysconfdir}/nginx/conf.d/wok.conf.in %{_sysconfdir}/nginx/conf.d/wok.conf -%{_sysconfdir}/logrotate.d/wokd.in %{_sysconfdir}/logrotate.d/wokd %{_var}/lib/wok/ %{_localstatedir}/log/wok/* diff --git a/contrib/wokd.logrotate.in b/contrib/wokd.logrotate.in deleted file mode 100644 index 8771d09..0000000 --- a/contrib/wokd.logrotate.in +++ /dev/null @@ -1,9 +0,0 @@ -${log_dir}/*log { - daily - nomail - maxsize 10M - rotate 10 - nomissingok - compress -} - diff --git a/src/wok/server.py b/src/wok/server.py index 902d4bf..6909b16 100644 --- a/src/wok/server.py +++ b/src/wok/server.py @@ -45,6 +45,16 @@ LOGGING_LEVEL = {"debug": logging.DEBUG, "warning": logging.WARNING, "error": logging.ERROR, "critical": logging.CRITICAL} +LOGROTATE_TEMPLATE = """ +${log_dir}/*log { + daily + nomail + maxsize 10M + rotate 10 + nomissingok + compress +} +""" def set_no_cache(): @@ -141,11 +151,7 @@ class Server(object): if paths.installed: # redefine logrotate configuration according to wok.conf - logrotate_file = os.path.join(paths.logrotate_dir, "wokd.in") - with open(logrotate_file) as template: - data = template.read() - - data = Template(data) + data = Template(LOGROTATE_TEMPLATE) data = data.safe_substitute(log_dir=configParser.get("logging", "log_dir")) -- 2.5.5

Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok.conf.in | 3 +++ src/wok/config.py.in | 1 + src/wok/server.py | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wok.conf.in b/src/wok.conf.in index 713c5a9..67dc75a 100644 --- a/src/wok.conf.in +++ b/src/wok.conf.in @@ -50,6 +50,9 @@ # Logging level: debug, info, warning, error or critical #log_level = debug +# Log file size (specify size in K, M or G) +#log_size = 10M + [authentication] # Authentication method, available option: pam, ldap. # method = pam diff --git a/src/wok/config.py.in b/src/wok/config.py.in index fd30fd6..1ca6f73 100644 --- a/src/wok/config.py.in +++ b/src/wok/config.py.in @@ -280,6 +280,7 @@ def _get_config(): config.add_section("logging") config.set("logging", "log_dir", paths.log_dir) config.set("logging", "log_level", DEFAULT_LOG_LEVEL) + config.set("logging", "log_size", "10M") config_file = os.path.join(paths.conf_dir, 'wok.conf') if os.path.exists(config_file): diff --git a/src/wok/server.py b/src/wok/server.py index 6909b16..567364d 100644 --- a/src/wok/server.py +++ b/src/wok/server.py @@ -49,7 +49,7 @@ LOGROTATE_TEMPLATE = """ ${log_dir}/*log { daily nomail - maxsize 10M + maxsize ${log_size} rotate 10 nomissingok compress @@ -153,7 +153,9 @@ class Server(object): # redefine logrotate configuration according to wok.conf data = Template(LOGROTATE_TEMPLATE) data = data.safe_substitute(log_dir=configParser.get("logging", - "log_dir")) + "log_dir"), + log_size=configParser.get("logging", + "log_size")) # Write file to be used for nginx. config_file = open(os.path.join(paths.logrotate_dir, "wokd"), "w") -- 2.5.5
participants (2)
-
Aline Manera
-
Ramon Medeiros