[Kimchi-devel] [PATCH][Wok] Issue #139: Do not generate logrotate config file on the fly
Aline Manera
alinefm at linux.vnet.ibm.com
Mon Oct 31 13:26:41 UTC 2016
Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>
On 10/31/2016 11:04 AM, Ramon Medeiros wrote:
> Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
> ---
> Makefile.am | 2 +-
> src/Makefile.am | 1 +
> src/wok.conf.in | 8 +++++---
> src/wok.logrotate | 9 +++++++++
> src/wok/server.py | 28 +---------------------------
> 5 files changed, 17 insertions(+), 31 deletions(-)
> create mode 100644 src/wok.logrotate
>
> diff --git a/Makefile.am b/Makefile.am
> index 8b3f508..4deadb1 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -155,7 +155,7 @@ 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/
> - touch $(DESTDIR)/etc/logrotate.d/wokd
> + $(INSTALL_DATA) $(top_srcdir)/src/wok.logrotate $(DESTDIR)/etc/logrotate.d/wokd
>
> uninstall-local:
> @if test -f $(systemdsystemunitdir)/wokd.service; then \
> diff --git a/src/Makefile.am b/src/Makefile.am
> index f06d755..27e0815 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -24,6 +24,7 @@ SUBDIRS = wok nginx
> EXTRA_DIST = wokd.in \
> wok.conf.in \
> firewalld.xml \
> + wok.logrotate \
> $(NULL)
>
> bin_SCRIPTS = wokd
> diff --git a/src/wok.conf.in b/src/wok.conf.in
> index 5e04b20..254f786 100644
> --- a/src/wok.conf.in
> +++ b/src/wok.conf.in
> @@ -50,14 +50,16 @@
>
> [logging]
> # Log directory
> +
> +# Be aware that editting logging directory, you must change logrotate
> +# configuration file to keep logs being compressed.
> +# Look /etc/logrotate.d/wokd
> +
> #log_dir = @localstatedir@/log/wok
>
> # 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.logrotate b/src/wok.logrotate
> new file mode 100644
> index 0000000..505c3e7
> --- /dev/null
> +++ b/src/wok.logrotate
> @@ -0,0 +1,9 @@
> +/var/log/wok {
> + daily
> + nomail
> + maxsize 10M
> + rotate 10
> + nomissingok
> + compress
> +}
> +
> diff --git a/src/wok/server.py b/src/wok/server.py
> index fecca48..9d864df 100644
> --- a/src/wok/server.py
> +++ b/src/wok/server.py
> @@ -30,7 +30,7 @@ from string import Template
> from wok import auth
> from wok import config
> from wok.config import config as configParser
> -from wok.config import paths, PluginConfig, WokConfig
> +from wok.config import PluginConfig, WokConfig
> from wok.control import sub_nodes
> from wok.model import model
> from wok.proxy import start_proxy
> @@ -45,17 +45,6 @@ LOGGING_LEVEL = {"debug": logging.DEBUG,
> "warning": logging.WARNING,
> "error": logging.ERROR,
> "critical": logging.CRITICAL}
> -LOGROTATE_TEMPLATE = """
> -${log_dir}/*log {
> - daily
> - nomail
> - maxsize ${log_size}
> - rotate 10
> - nomissingok
> - compress
> -}
> -"""
> -
>
> def set_no_cache():
> from time import strftime, gmtime
> @@ -147,21 +136,6 @@ class Server(object):
> # start request logger
> self.reqLogger = RequestLogger()
>
> - # only add logrotate if wok is installed
> - if paths.installed:
> -
> - # redefine logrotate configuration according to wok.conf
> - data = Template(LOGROTATE_TEMPLATE)
> - data = data.safe_substitute(
> - log_dir=configParser.get("logging", "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")
> - config_file.write(data)
> - config_file.close()
> -
> # Handling running mode
> if not dev_env:
> cherrypy.config.update({'environment': 'production'})
More information about the Kimchi-devel
mailing list