Configure logrotate
This adds a logrotate configuration for Heka when systemd is not used.
diff --git a/heka/_service.sls b/heka/_service.sls
index 535e5cb..359e716 100644
--- a/heka/_service.sls
+++ b/heka/_service.sls
@@ -53,6 +53,16 @@
- mode: 644
- replace: false
+/etc/logrotate.d/{{ service_name }}:
+ file.managed:
+ - source: salt://heka/files/heka_logrotate.conf
+ - template: jinja
+ - defaults:
+ service_name: {{ service_name }}
+ - user: root
+ - group: root
+ - mode: 644
+
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
new file mode 100644
index 0000000..2e290ad
--- /dev/null
+++ b/heka/files/heka_logrotate.conf
@@ -0,0 +1,21 @@
+/var/log/{{ service_name }}.log {
+ # Heka cannot be told to close its log file and re-open it so we need to
+ # use the copytruncate option
+ copytruncate
+ compress
+ delaycompress
+ missingok
+ notifempty
+ # logrotate allows to use only year, month, day and unix epoch
+ dateext
+ dateformat -%Y%m%d-%s
+ # number of rotated files to keep
+ rotate 10
+ # do not rotate files unless both size and time conditions are met
+ hourly
+ minsize 20M
+ # force rotate if filesize exceeded 100M
+ maxsize 100M
+ # this must map the /var/log directory group ownership
+ su root syslog
+}