[Kimchi-devel] [PATCH][Wok 1/2] Issue #118: logrotate fails

Ramon Medeiros ramonn at linux.vnet.ibm.com
Fri Jun 10 14:50:50 UTC 2016


Create file only when server is started

Signed-off-by: Ramon Medeiros <ramonn at 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




More information about the Kimchi-devel mailing list