2

I have this in logrotate.d/varnish file:

/var/log/varnish/*log {
                create 640 http log
                compress
                postrotate
                        /bin/kill -USR1 `cat /var/run/varnishncsa.pid 2>/dev/null` 2> /dev/null || true
                endscript
        }

And this in my /etc/rc.local file:

varnishncsa -a -w /var/log/varnish/access.log -D -P /var/run/varnishncsa.pid

But when logrotate creates a new access.log file, it remains blank. I have to do sh /etc/rc.local for logs to be saved in that file. As logrotation happens weekly, I have to execute that rc.local every week to get the logs saved in access.log file. What can be the issue here?

Phil Hollenback
  • 14,947
  • 4
  • 35
  • 52
nixnotwin
  • 1,543
  • 5
  • 35
  • 55
  • Did you get `varnishncsa` running after execute `logrotate`? Which distro are you running? – quanta Aug 09 '11 at 15:28
  • Yes it will be running after logrotate gets executed. The distro I'm running is ubuntu 10.04. – nixnotwin Aug 09 '11 at 16:39
  • Could you please run `logrotate` manually and give us output: `logrotate -v -f /etc/logrotate.d/varnish`? – quanta Aug 10 '11 at 02:31

1 Answers1

2

I know absolutely nothing about varnish, but it sure looks like you should be sending it a SIGHUP to do log rotation, not a SIGUSR1.

A new blank logfile is a pretty good indicator that the daemon isn't getting the message that it's supposed to close it's old logfile and switch to a new one.

Phil Hollenback
  • 14,947
  • 4
  • 35
  • 52
  • 'SIGHUP' didn't work. – nixnotwin Aug 16 '11 at 12:21
  • SIGHUP is pretty much the universal 'tell a daemon to close and reopen logfile' signal. I'm confused why if sighup didn't work you thought sigusr1 would? Well, it's certainly possible that varnish uses sigusr1, like I said I'm not knowledgeable about it. But, I wonder if the problem is still that something is wrong with sighup handling in your version of varnish. – Phil Hollenback Aug 18 '11 at 01:02
  • @nixnotwin: It's kill -HUP, not -SIGHUP – Thiago Figueiro May 02 '12 at 08:25
  • Tested both, HUP actually kills the process and USR1 does nothing. USR2 also did nothing. So ended up just restarting the process. – dalore Nov 28 '17 at 19:02