about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-03-29 09:47:26 -0700
committerEric Wong <normalperson@yhbt.net>2011-03-29 09:47:26 -0700
commitc1ebb313735a280582d87c1ba44619aa47e00b06 (patch)
treec255cc22801ae4640f981ecc19148cd29bcfcb0b
parentede28dc59562c862ff4641ed42a0ef357880d0f5 (diff)
downloadunicorn-c1ebb313735a280582d87c1ba44619aa47e00b06.tar.gz
logrotate is the de facto tool for logrotation, so an
example config for highlighting important parts are in order.

Since our USR1 signal handling is part of the crusade against
the slow and lossy "copytruncate" option, be sure to
emphasize that :)
-rw-r--r--examples/logrotate.conf29
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/logrotate.conf b/examples/logrotate.conf
new file mode 100644
index 0000000..03fefc6
--- /dev/null
+++ b/examples/logrotate.conf
@@ -0,0 +1,29 @@
+# example logrotate config file, I usually keep this in
+# /etc/logrotate.d/unicorn_app on my Debian systems
+#
+# See the logrotate(8) manpage for more information:
+#    http://linux.die.net/man/8/logrotate
+
+# Modify the following glob to match the logfiles your app writes to:
+/var/log/unicorn_app/*.log {
+        # this first block is mostly just personal preference, though
+        # I wish logrotate offered an "hourly" option...
+        daily
+        missingok
+        rotate 180
+        compress # must use with delaycompress below
+        dateext
+
+        # this is important if using "compress" since we need to call
+        # the "lastaction" script below before compressing:
+        delaycompress
+
+        # note the lack of the evil "copytruncate" option in this
+        # config.  Unicorn supports the USR1 signal and we send it
+        # as our "lastaction" action:
+        lastaction
+                # assuming your pid file is in /var/run/unicorn_app/pid
+                pid=/var/run/unicorn_app/pid
+                test -s $pid && kill -USR1 "$(cat $pid)"
+        endscript
+}