rotating the varnishncsa log file
Raymond Hall
kova70 at gmail.com
Fri Sep 5 04:37:16 CEST 2008
On Thu, Sep 4, 2008 at 8:02 PM, Chris Johnson <cjohnson at socialvibe.com> wrote:
> Does anyone successfully have logrotate working with varnishncsa?
On a RHEL5 machine:
(the DAEMON var in the initscript is set to varnishncsa-hack because
its a havcked version that writes the host header, just replace it
with varnishncsa, presto! :)
I have this logrotate conf:
[kovalski at 175384-proxy1 ~]$ cat /etc/logrotate.d/varnish
/var/log/varnish/varnish.log {
daily
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/varnish/varnishlog.pid
2>/dev/null` 2> /dev/null || true
endscript
}
And this init script:
[kovalski at 175384-proxy1 ~]$ cat /etc/init.d/varnishlog
#! /bin/sh
#
# varnishlog Control the varnish HTTP accelerator logging daemon
#
# chkconfig: - 90 10
# description: HTTP accelerator logging daemon
# processname: varnishlog
# config:
# pidfile: /var/run/varnish/varnishlog.pid
# Source function library.
. /etc/init.d/functions
RETVAL=0
PROCNAME=varnishlog
DAEMON="/usr/bin/varnishncsa-hack"
PIDFILE="/var/run/varnish/varnishlog.pid"
LOCKFILE="/var/lock/subsys/varnishlog"
LOGFILE="/var/log/varnish/varnish.log"
DAEMON_OPTS="-c -a -w ${LOGFILE} -D -P $PIDFILE"
mkdir -p /var/run/varnish 2>/dev/null
# See how we were called.
case "$1" in
start)
echo -n "Starting varnish logging daeon: "
daemon --pidfile $PIDFILE $DAEMON "$DAEMON_OPTS"
sleep 1
pkill -0 $PROCNAME
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
echo_success
touch $LOCKFILE
else
echo_failure
fi
echo
;;
stop)
echo -n "Stopping varnish logging daemon: "
killproc -p $PIDFILE $DAEMON
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
echo_success
rm -f $LOCKFILE $PIDFILE
else
echo_failure
fi
echo
;;
status)
status -p $PIDFILE $PROCNAME
RETVAL=$?
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
condrestart)
if [ -f $PIDFILE ]; then
$0 stop
$0 start
RETVAL=$?
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart|condrestart}"
exit 1
esac
exit $RETVAL
>
> Thanks,
> Chrs
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>
--
I'd rather have an inch of a dog than miles of pedigree.
Dana Burnet
More information about the varnish-misc
mailing list