[PATCH][Wok] Issue #118: logrotate fails

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

Hi, can user have his own configuration for logrotate? like modifying "wokd.in" and having customized settings after installation?(not sure if its a valid usecase) I see that this code moves "wokd.in" configuration to server.py,, so if user has his own settings for wok in logrotate.d, it will be overwritten by default configuration when wokd is restarted. So no option for user to have customized settings? On 06/09/2016 02:32 AM, Ramon Medeiros wrote:
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"))
-- Regards, Suresh Babu Angadi

Yes, in this case, the only thing that user can change is log_dir (on kimchi configuration). Nothing else :( On 06/10/2016 06:01 AM, Suresh Babu Angadi wrote:
Hi, can user have his own configuration for logrotate? like modifying "wokd.in" and having customized settings after installation?(not sure if its a valid usecase)
I see that this code moves "wokd.in" configuration to server.py,, so if user has his own settings for wok in logrotate.d, it will be overwritten by default configuration when wokd is restarted. So no option for user to have customized settings?
On 06/09/2016 02:32 AM, Ramon Medeiros wrote:
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"))
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com

On 06/10/2016 06:05 PM, Ramon Medeiros wrote:
Yes,
in this case, the only thing that user can change is log_dir (on kimchi configuration). Nothing else :(
I was referring to settings like maxsize, frequency (daily, weekly) etc. If so, we can move "wokd.in" from /etc/logrotate.d/ to some directory like "/etc/wok/" with file name as "wokd.logrotate.in" and document the same.
On 06/10/2016 06:01 AM, Suresh Babu Angadi wrote:
Hi, can user have his own configuration for logrotate? like modifying "wokd.in" and having customized settings after installation?(not sure if its a valid usecase)
I see that this code moves "wokd.in" configuration to server.py,, so if user has his own settings for wok in logrotate.d, it will be overwritten by default configuration when wokd is restarted. So no option for user to have customized settings?
On 06/09/2016 02:32 AM, Ramon Medeiros wrote:
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"))
-- Regards, Suresh Babu Angadi
participants (2)
-
Ramon Medeiros
-
Suresh Babu Angadi