Merge pull request #97 from elemoine/log-rotate
No longer use a specific logrotate script for Heka logs
diff --git a/heka/_service.sls b/heka/_service.sls
index 687b30d..359e716 100644
--- a/heka/_service.sls
+++ b/heka/_service.sls
@@ -53,9 +53,7 @@
- mode: 644
- replace: false
-{%- set logrotate_conf = "/etc/logrotate_" ~ service_name ~ ".conf" %}
-
-{{ logrotate_conf }}:
+/etc/logrotate.d/{{ service_name }}:
file.managed:
- source: salt://heka/files/heka_logrotate.conf
- template: jinja
@@ -65,26 +63,6 @@
- group: root
- mode: 644
-{%- set logrotate_command = "/usr/local/bin/" ~ service_name ~ "_logrotate" %}
-
-{{ logrotate_command }}:
- file.managed:
- - source: salt://heka/files/heka_logrotate.cron
- - template: jinja
- - defaults:
- service_name: {{ service_name }}
- logrotate_conf: {{ logrotate_conf }}
- - user: root
- - group: root
- - mode: 755
- - require:
- - file: {{ logrotate_conf }}
- cron.present:
- - identifier: {{ service_name }}_logrotate_cron
- - minute: '*/30'
- - require:
- - file: {{ logrotate_command }}
-
heka_{{ service_name }}_service_wrapper:
file.managed:
- name: /usr/local/bin/{{ service_name }}_wrapper
diff --git a/heka/files/heka_logrotate.conf b/heka/files/heka_logrotate.conf
index 2e290ad..9e35b33 100644
--- a/heka/files/heka_logrotate.conf
+++ b/heka/files/heka_logrotate.conf
@@ -12,10 +12,8 @@
# number of rotated files to keep
rotate 10
# do not rotate files unless both size and time conditions are met
- hourly
+ daily
minsize 20M
# force rotate if filesize exceeded 100M
maxsize 100M
- # this must map the /var/log directory group ownership
- su root syslog
}
diff --git a/heka/files/heka_logrotate.cron b/heka/files/heka_logrotate.cron
deleted file mode 100644
index cc3e249..0000000
--- a/heka/files/heka_logrotate.cron
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-
-test -x /usr/sbin/logrotate || exit 0
-
-LOCK_FILE="/var/lock/logrotate.{{ service_name }}.lock"
-
-lock() {
- exec 903>$LOCK_FILE
- flock -n 903 && return 0 || return 1
-}
-
-unlock() {
- flock -u 903
-}
-
-fail() {
- if [ -z "$1" ]
- then
- MESSAGE="WARNING logrotate failed, no reason provided"
- else
- MESSAGE=$1
- fi
- /usr/bin/logger -t logrotate "{{ service_name }} ${MESSAGE}"
- unlock
- exit 1
-}
-
-lock || fail "WARNING {{ service_name }} logrotate flock failed, exiting"
-
-
-TMP_FILE=$(/bin/mktemp)
-nice ionice -c3 /usr/sbin/logrotate -s /var/lib/logrotate/{{ service_name }}.status {{ logrotate_conf }} >& $TMP_FILE
-EXITVALUE=$?
-
-if [ -f /etc/redhat-release ] || [ -f /etc/centos-release ];
-then
- # Due to bug in logrotate on centos/rhel, it always returns 0. Use grep for
- # detect errors; exit code 1 is considered a success as no errors were
- # found.
- grep -q error $TMP_FILE
- EXITVALUE=$?
- EXPECTEDVALUE=1
-else
- EXPECTEDVALUE=0
-fi
-rm $TMP_FILE
-
-if [ "${EXITVALUE}" != "${EXPECTEDVALUE}" ]; then
- fail "ALERT exited abnormally with [${EXITVALUE}] (${EXPECTEDVALUE} was expected)"
-fi
-
-unlock
-exit 0