[Kimchi-devel] [PATCH] [Wok 2/5] Install cron for cleaning User Request Logs
Aline Manera
alinefm at linux.vnet.ibm.com
Fri Feb 26 13:31:21 UTC 2016
Hi Lucio,
Instead of setup cron, we can use the cherrypy plugins to execute a task
on every time.
Please, take a look at
http://docs.cherrypy.org/en/latest/pkg/cherrypy.process.html
Seems BackgroundTask will fit our needs here:
http://docs.cherrypy.org/en/latest/pkg/cherrypy.process.html#cherrypy.process.plugins.BackgroundTask
We can register the plugin on server start up and let it run on every
time you need to check the logs.
On 02/25/2016 05:47 PM, Lucio Correia wrote:
> Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
> ---
> Makefile.am | 10 ++++++++++
> contrib/DEBIAN/control.in | 1 +
> contrib/Makefile.am | 1 +
> contrib/cleanlogs.sh | 4 ++++
> contrib/wok.spec.fedora.in | 2 ++
> contrib/wok.spec.suse.in | 2 ++
> 6 files changed, 20 insertions(+)
> create mode 100644 contrib/cleanlogs.sh
>
> diff --git a/Makefile.am b/Makefile.am
> index 86d83a0..584c695 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -95,6 +95,10 @@ install-deb: install
> $(DESTDIR)/etc/init/wokd.conf; \
> fi
> $(MKDIR_P) $(DESTDIR)/$(localstatedir)/lib/wok/
> + $(MKDIR_P) $(DESTDIR)/$(localstatedir)/lib/wok/logs
> + $(MKDIR_P) $(DESTDIR)/etc/cron.daily
> + cp -R $(top_srcdir)/contrib/cleanlogs.sh \
> + $(DESTDIR)/etc/cron.daily/wok-cleanlogs
> $(MKDIR_P) $(DESTDIR)/usr/lib/firewalld/services
> cp -R $(top_srcdir)/src/firewalld.xml \
> $(DESTDIR)/usr/lib/firewalld/services/wokd.xml
> @@ -146,6 +150,10 @@ install-data-local:
> $(INSTALL_DATA) src/firewalld.xml $(DESTDIR)/usr/lib/firewalld/services/wokd.xml; \
> fi; \
> mkdir -p $(DESTDIR)/$(localstatedir)/lib/wok/
> + $(MKDIR_P) $(DESTDIR)/$(localstatedir)/lib/wok/logs
> + $(MKDIR_P) $(DESTDIR)/etc/cron.daily
> + $(INSTALL_DATA) contrib/cleanlogs.sh $(DESTDIR)/etc/cron.daily/wok-cleanlogs
> + chmod +x $(DESTDIR)/etc/cron.daily/wok-cleanlogs
> mkdir -p $(DESTDIR)/$(localstatedir)/log/wok/
> touch $(DESTDIR)/$(localstatedir)/log/wok/wok-access.log
> touch $(DESTDIR)/$(localstatedir)/log/wok/wok-error.log
> @@ -166,9 +174,11 @@ uninstall-local:
> if test -d /usr/lib/firewalld/services/; then \
> $(RM) $(DESTDIR)/usr/lib/firewalld/services/wokd.xml; \
> fi; \
> + $(RM) -rf $(DESTDIR)/$(localstatedir)/lib/wok/logs
> $(RM) -rf $(DESTDIR)/$(localstatedir)/lib/wok
> $(RM) -rf $(DESTDIR)/$(localstatedir)/log/wok
> $(RM) -rf $(DESTDIR)/etc/wok
> + $(RM) $(DESTDIR)/etc/cron.daily/wok-cleanlogs
> $(RM) $(DESTDIR)/etc/nginx/conf.d/wok.conf
> $(RM) $(DESTDIR)/etc/logrotate.d/wokd.in
> $(RM) $(DESTDIR)/etc/logrotate.d/wokd
> diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in
> index e585080..bf0e751 100644
> --- a/contrib/DEBIAN/control.in
> +++ b/contrib/DEBIAN/control.in
> @@ -15,6 +15,7 @@ Depends: python-cherrypy3 (>= 3.2.0),
> python-psutil (>= 0.6.0),
> fonts-font-awesome,
> logrotate,
> + cron,
> texlive-fonts-extra
> Build-Depends: xsltproc,
> gettext,
> diff --git a/contrib/Makefile.am b/contrib/Makefile.am
> index a82ba30..fdc8d2c 100644
> --- a/contrib/Makefile.am
> +++ b/contrib/Makefile.am
> @@ -30,6 +30,7 @@ EXTRA_DIST = \
> wokd-upstart.conf.fedora \
> make-deb.sh.in \
> wokd.logrotate.in \
> + cleanlogs.sh \
> $(NULL)
>
> make-deb.sh: make-deb.sh.in $(top_builddir)/config.status
> diff --git a/contrib/cleanlogs.sh b/contrib/cleanlogs.sh
> new file mode 100644
> index 0000000..b916d67
> --- /dev/null
> +++ b/contrib/cleanlogs.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +
> +DIR=/var/lib/wok/logs
> +[ -d "$DIR" ] && find "$DIR" -mtime +1 -type f -delete
> diff --git a/contrib/wok.spec.fedora.in b/contrib/wok.spec.fedora.in
> index 7715e7f..40b247f 100644
> --- a/contrib/wok.spec.fedora.in
> +++ b/contrib/wok.spec.fedora.in
> @@ -20,6 +20,7 @@ Requires: python-psutil >= 0.6.0
> Requires: fontawesome-fonts
> Requires: open-sans-fonts
> Requires: logrotate
> +Requires: crontabs
> BuildRequires: gettext-devel
> BuildRequires: libxslt
> BuildRequires: openssl
> @@ -114,6 +115,7 @@ rm -rf $RPM_BUILD_ROOT
> %{_prefix}/share/locale/*/LC_MESSAGES/wok.mo
> %{_datadir}/wok/ui/
> %{_datadir}/wok
> +%{_sysconfdir}/cron.daily/wok-cleanlogs
> %{_sysconfdir}/nginx/conf.d/wok.conf.in
> %{_sysconfdir}/wok/wok.conf
> %{_sysconfdir}/wok/
> diff --git a/contrib/wok.spec.suse.in b/contrib/wok.spec.suse.in
> index 3d39483..edbf7a0 100644
> --- a/contrib/wok.spec.suse.in
> +++ b/contrib/wok.spec.suse.in
> @@ -21,6 +21,7 @@ Requires: python-psutil >= 0.6.0
> Requires: fontawesome-fonts
> Requires: google-opensans-fonts
> Requires: logrotate
> +Requires: cronie
> BuildRequires: gettext-tools
> BuildRequires: libxslt-tools
> BuildRequires: openssl
> @@ -91,6 +92,7 @@ rm -rf $RPM_BUILD_ROOT
> %{_prefix}/share/locale/*/LC_MESSAGES/wok.mo
> %{_datadir}/wok/ui/
> %{_datadir}/wok
> +%{_sysconfdir}/cron.daily/wok-cleanlogs
> %{_sysconfdir}/wok/wok.conf
> %{_sysconfdir}/wok/
> %{_sysconfdir}/nginx/conf.d/wok.conf.in
More information about the Kimchi-devel
mailing list