Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 296168 - www-servers/nginx - Missing logrotate script
Summary: www-servers/nginx - Missing logrotate script
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Konstantin Arkhipov (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-08 08:53 UTC by macindy
Modified: 2010-01-03 20:33 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description macindy 2009-12-08 08:53:03 UTC
There is no logrotate script for nginx with logrotate.
Here is my sugestions for
/etc/logrotate.d/nginx:
/var/log/nginx/* {
    missingok
    sharedscripts
    postrotate
                if [ -f /var/run/nginx.pid ]; then
                        /etc/init.d/nginx restart > /dev/null
                fi
    endscript
}


Reproducible: Always

Steps to Reproduce:
Comment 1 Gef 2009-12-08 13:53:58 UTC
nginx as built-in support for instant log-rotation using USR1 signal:

/var/log/nginx/*_log {
        missingok
        sharedscripts
        postrotate
		kill -USR1 `cat /var/run/nginx.pid`
        endscript
}
Comment 2 Johan Bergström 2009-12-08 14:25:21 UTC
(In reply to comment #1)
> nginx as built-in support for instant log-rotation using USR1 signal:
> 
> /var/log/nginx/*_log {
>         missingok
>         sharedscripts
>         postrotate
>                 kill -USR1 `cat /var/run/nginx.pid`
>         endscript
> }
> 

I would prefer using /etc/init.d/nginx reload instead of kill for this task. the init script's reload() should also switch from HUP to USR1 - but that's another issue. 
Comment 3 Gef 2009-12-18 20:31:52 UTC
About Nginx handling of signals, docs [1] says the following :
HUP: 
`- Configuration reload
`-Start the new worker processes with a new configuration
`-Gracefully shutdown the old worker processes
USR1
`-Reopen the log files
USR2
`-Upgrade Executable on the fly

So using USR1 to reopen logs after rotation seems sane.

[1] http://wiki.nginx.org/NginxCommandLine#Controlling_Nginx_Via_the_Signals
Comment 4 Dirkjan Ochtman (RETIRED) gentoo-dev 2010-01-03 20:31:46 UTC
I've added a logrotate script to 0.7.64-r3 (and will port it to 0.8.x soon).