jackyfkc.github.io

教土豆学计算机

Controlling nginx

nginx can be controlled with signals. The process ID of the master process is written to the file /usr/local/nginx/logs/nginx.pid by default. This name may be changed at configuration time, or in nginx.conf using the pid directive.

The master process supports the following signals:

Individual worker processes can be controlled with signals as well, though it is not required. The supported signals are:

Updating Configuration and Upgrading Nginx

Updating NGINX configuration is a very simple, lightweight, and reliable operation. It typically just means running the nginx –s reload command, which checks the configuration on disk and sends the master process a SIGHUP signal.

Loading new configuration with no downtime

When the master process receives a SIGHUP, it does two things:

Loading new Nginx binary with no downtime

  1. Reloads the configuration and forks a new set of worker processes. These new worker processes immediately begin accepting connections and processing traffic (using the new configuration settings).

  2. Signals the old worker processes to gracefully exit. The worker processes stop accepting new connections. As soon as each current HTTP request completes, the worker process cleanly shuts down the connection (that is, there are no lingering keepalives). Once all connections are closed, the worker processes exit.

References