Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Misc

Syntax for piping varnish logs to rotatelogs

 

 

Varnish misc RSS feed   Index | Next | Previous | View Threaded


rowan at jetboy

Jun 26, 2012, 10:01 AM

Post #1 of 4 (592 views)
Permalink
Syntax for piping varnish logs to rotatelogs

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.


_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


hugo.cisneiros at gmail

Jun 26, 2012, 10:49 AM

Post #2 of 4 (572 views)
Permalink
Re: Syntax for piping varnish logs to rotatelogs [In reply to]

On Tue, Jun 26, 2012 at 2:01 PM, Rowan @ Jetboy <rowan [at] jetboy> wrote:
> 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
[...]

I don't really know if this is the issue you're running, but maybe it
its. Check this out:

http://my.opera.com/cstrep/blog/2011/11/30/how-to-start-up-varnish-with-a-custom-cc-command-on-debian

I had some problems adding the -F to varnishncsa daemon and it worked.
Attaching the "bash -c" before the start-stop-daemon did the trick.
Maybe the init script is ignoring your parameters for the same reason.

--
[]'s
Hugo
www.devin.com.br

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


rowan at jetboy

Jun 26, 2012, 2:46 PM

Post #3 of 4 (572 views)
Permalink
RE: Syntax for piping varnish logs to rotatelogs [In reply to]

Thanks Hugo,

I think you've got it there. I've just had a response on Server Fault that
seems to be based around the similar logic:

http://serverfault.com/questions/402157/syntax-for-piping-varnish-logs-to-ro
tatelogs/402506#402506

Am I right in thinking that this is the same limitation that prevents you
passing arguments that contain spaces out from /etc/default/varnish and
/etc/default/varnishncsa? Hacking init files seems like a bad idea, but
there really doesn't seem to be another option. I'll give it a try and post
back.

<snip>

> 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
[...]

I don't really know if this is the issue you're running, but maybe it its.
Check this out:

http://my.opera.com/cstrep/blog/2011/11/30/how-to-start-up-varnish-with-a-cu
stom-cc-command-on-debian

I had some problems adding the -F to varnishncsa daemon and it worked.
Attaching the "bash -c" before the start-stop-daemon did the trick.
Maybe the init script is ignoring your parameters for the same reason.

</snip>


_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


hugo.cisneiros at gmail

Jun 26, 2012, 2:50 PM

Post #4 of 4 (562 views)
Permalink
Re: Syntax for piping varnish logs to rotatelogs [In reply to]

On Tue, Jun 26, 2012 at 6:46 PM, Rowan @ Jetboy <rowan [at] jetboy> wrote:
> Thanks Hugo,
>
> I think you've got it there. I've just had a response on Server Fault that
> seems to be based around the similar logic:
>
> http://serverfault.com/questions/402157/syntax-for-piping-varnish-logs-to-ro
> tatelogs/402506#402506
>
> Am I right in thinking that this is the same limitation that prevents you
> passing arguments that contain spaces out from /etc/default/varnish and
> /etc/default/varnishncsa? Hacking init files seems like a bad idea, but
> there really doesn't seem to be another option. I'll give it a try and post
> back.

Yes, it's the same bug. And since it's a bug, I think it's OK to hack
the init script until the upstream fixes it (and hopefully they will
fix :)

--
[]'s
Hugo
www.devin.com.br

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Varnish misc RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.