Syntax for piping varnish logs to rotatelogs

Rowan @ Jetboy rowan at jetboy.co.uk
Tue Jun 26 19:01:41 CEST 2012


Ubuntu 12.04 Server x64, Varnish 3.0.2

I'm trying to pipe varnishncsa's logs through Apache's rotatelogs, and
running from the shell, things work fine:

sudo varnishncsa -a -P /var/run/varnishncsa/varnishncsa.pid
|/usr/sbin/rotatelogs /var/log/varnish/varnish.log.%Y%m%d%H 3600

creates a new logfile in /var/log/varnish, with rotation every hour (3600
seconds). However, I'm struggling to get things working the same way inside
/etc/init.d/varnishncsa:

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME/$NAME.pid
LOGFILE=/var/log/varnish/varnishncsa.log
USER=varnishlog

DAEMON_OPTS="-a -P ${PIDFILE}"
DAEMON_PIPE="|/usr/sbin/rotatelogs /var/log/varnish/varnish.log.%Y%m%d%H
3600"

...

start_varnishncsa() {
    output=$(/bin/tempfile -s.varnish)
    log_daemon_msg "Starting $DESC" "$NAME"
    create_pid_directory
    if start-stop-daemon --start --verbose --pidfile ${PIDFILE} \
        --chuid $USER --exec ${DAEMON} -- ${DAEMON_OPTS} \
        > ${output} 2>&1; then
        log_end_msg 0
    else
        log_end_msg 1
        cat $output
        exit 1
    fi
    rm $output
}


Where should I put DAEMON_PIPE in the above code? I've tried at the end of:

if start-stop-daemon --start --verbose --pidfile ${PIDFILE}

which is where additional command line parameters usually go, but it isn't
creating a logfile.




More information about the varnish-misc mailing list