Intercepting USR1 in a module

Andrew Punch apunch at
Thu Feb 13 00:15:41 UTC 2014


I am maintaining a custom module for nginx. We currently rotate our logs
and load dynamic data every 5 minutes by using SIGHUP. Unfortunately this
is also tears down our keepalive connections which harms our performance
(we are handling about 1500 requests per second per server). We have a
number of custom log files in addition to the access log and error log
which also need to be rotated.

I was hoping that I could use SIGUSR1 to reopen the logs (including the
module's custom logs) and notify the module that it should reload the
dynamic data without dropping the keepalive connections.

I can see that I could use ngx_conf_open_file() to open the module's custom
log files so that nginx will take care of reopening them. However for
reloading the dynamic data: I can't see a way to hook the SIGUSR1 in the
worker process (which shows up as a NGX_CMD_REOPEN in the channel for the
worker process). However if I added a new hook for NGX_CMD_REOPEN then
epoll inside the channel handler would probably return EEXIST.

So what is the best way for a module to hook NGX_CMD_REOPEN? Or is there
better way of approaching this?



This e-mail and any attachments are confidential and may contain copyright 
material of Brandscreen or third parties. If you are not the intended 
recipient of this email you should not read, print, re-transmit, store or 
act in reliance on this e-mail or any attachments, and should destroy all 
copies of them. Brandscreen does not guarantee the integrity of any emails 
or any attached files. The views or opinions expressed are the author's own 
and may not reflect the views or opinions of Brandscreen.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list