Welcome! Log In Create A New Profile

Advanced

Re: Empty error and access log

Francis Daly
September 27, 2019 03:08AM
On Fri, Sep 27, 2019 at 01:36:55AM -0400, krishna wrote:

Hi there,

I do not have the answer for you. But...

> Figured out that, nginx.pid file doesn't have the correct PID value(it
> contains 1) - which could be valid since nginx is running inside docker
> container and we are setting up the log rotation from the host machine where
> the log files getting rotated but new files not getting logged further by
> nginx worker process.
>
> As per the comments tried to edit the nginx.pid file(with Nginx host PID),
> then issued command "kill -USR1 `cat /var/run/nginx.pid`" which works fine
> and new log files getting created and logged with data.

....what nginx needs is for its master process to receive a "USR1"
signal. It does not care how that is done.

As I understand it, docker includes a "kill" subcommand with a "-s" option
to send a specific signal to a container -- which should mean "to the
one process that is running in the container", which in your case should
be nginx.

> Had came across the blogs, they suggested to use nginx reload during post
> rotation as below with the logrotate,
> postrotate
> docker exec nginx bash -c "nginx -s reload 2>/dev/null"
> endscript
>
> Kindly let me know, if above is a valid approach can be followed (or) to
> get the actual Nginx PID at host level & initiate kill command with USR1.

I think that there were good reasons explained not to send HUP when USR1
is all that is needed.

nginx writes its pid file to a well-known place. If "something else"
does virtualising or jailing or containerising or namespacing or any
other translation between nginx's idea of its pid and the rest of the
world's idea of the nginx pid, then it is that "something else's" job
to untranslate as well.

Which means: if you use docker to hide nginx from the system, you should
use docker to expose nginx to the system.

Ask docker for the "real" pid; or use docker to avoid having to find
the pid.

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Empty error and access log

krishna September 26, 2019 06:22AM

Re: Empty error and access log

krishna September 26, 2019 06:24AM

Re: Empty error and access log

Francis Daly September 26, 2019 07:10AM

Re: Empty error and access log

krishna September 26, 2019 07:25AM

Re: Empty error and access log

rick_pri September 26, 2019 09:13AM

Re: Empty error and access log

Francis Daly September 26, 2019 11:00AM

Re: Empty error and access log

Maxim Dounin September 26, 2019 11:10AM

Re: Empty error and access log

Maxim Dounin September 26, 2019 11:14AM

Re: Empty error and access log

krishna September 27, 2019 01:36AM

Re: Empty error and access log

Francis Daly September 27, 2019 01:58AM

Re: Empty error and access log

Francis Daly September 27, 2019 03:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 264
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready