rotating the varnishncsa log file
Chris Johnson
cjohnson at socialvibe.com
Tue Sep 23 01:44:38 CEST 2008
Thank you for your replies Raymond and Nathan.
Can you possibly shed some light on the " /usr/sbin/invoke-rc.d"
part? Read on for more context...
I want to use logrotate to rotate the varnish log files. I found the
file (/home/username/varnish-1.1.1/debian/varnish.logrotate)
containing the following:
>>>
/var/log/varnish/varnish.log {
daily
rotate 7
compress
delaycompress
postrotate
/usr/sbin/invoke-rc.d varnishlog reload > /dev/null
endscript
}
>>>
However, we are using varnishncsa and not varnishlog. Running "ps aux
| grep varnish" yields:
>>
/opt/varnish/sbin/varnishd
/opt/varnish/bin/varnishncsa -a -c -w /var/log/varnish.log
>>
Is setting up logrotate for varnishncsa as simple as changing the
invoke-rc.d line of the logrotate file to be:
>>
/usr/sbin/invoke-rc.d varnishncsa reload > /dev/null
>>
If so, how to pass in the ncsa commandline parameters?
Thanks for any guidance.
-Chris
On Sep 5, 2008, at 10:39 AM, Nathan Kinkade wrote:
> 2008/9/4 Chris Johnson <cjohnson at socialvibe.com>:
>> Does anyone successfully have logrotate working with varnishncsa?
>>
>> Thanks,
>> Chrs
>
> Below is the solution I came up with. The lastaction part may not be
> necessary for anyone else, but on occasion it seemed to be necessary
> for us, and rather than spending much time looking into the underlying
> cause I'm okay with this solution.
>
> Nathan
>
> /etc/logrotate.d/varnish
> ===========================
> /var/log/varnish/varnish.log {
> daily
> rotate 52
> compress
> create
> delaycompress
> dateext
> postrotate
> /usr/sbin/invoke-rc.d varnishlog reload > /dev/null
> DATE=$(date +%Y%m%d)
> VDIR=/var/log/varnish
> # varnishlog or varnishncsa(??) seems to produce a lot of entries
> that are null,
> # the grep -v in the middle just attempts to eliminate them
> /usr/bin/ionice -c3 /usr/bin/varnishncsa -r
> $VDIR/varnish.log-$DATE | grep -v '^- - -' | gzip >
> $VDIR/varnish.log-$DATE.gz && rm $VDIR/varnish.log-
> $DATE
> endscript
> lastaction
> # Sometimes, for reasons that I can't explain, varnishlog stops
> logging after
> # rotation. The new log just sits there at 0 bytes and it takes
> a reload to
> # make it start logging again. It could be some complex timing
> issue, but
> # hopefully just adding one last restart of varnishlog will be
> enough.
> /usr/sbin/invoke-rc.d varnishlog force-reload > /dev/null
> endscript
> }
> ===========================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20080922/46300377/attachment-0001.html>
More information about the varnish-misc
mailing list