Skip to content

Commit c091c80

Browse files
committed
til: nginx reload
1 parent e23ccfe commit c091c80

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

nginx/control.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Controlling Nginx
2+
3+
Source: <http://nginx.org/en/docs/control.html>
4+
5+
## How nginx reload work ? why it is zero-downtime?
6+
7+
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:
8+
9+
```text
10+
TERM, INT fast shutdown
11+
QUIT graceful shutdown
12+
HUP changing configuration, keeping up with a changed time zone (only for FreeBSD and Linux), starting new worker processes with a new configuration, graceful shutdown of old worker processes
13+
USR1 re-opening log files
14+
USR2 upgrading an executable file
15+
WINCH graceful shutdown of worker processes
16+
```
17+
18+
Individual worker processes can be controlled with signals as well, though it is not required. The supported signals are:
19+
20+
```text
21+
TERM, INT fast shutdown
22+
QUIT graceful shutdown
23+
USR1 re-opening log files
24+
WINCH abnormal termination for debugging (requires debug_points to be enabled)
25+
```
26+
27+
In order for nginx to re-read the configuration file, a HUP signal should be sent to the master process. The master process first checks the syntax validity, then tries to apply new configuration, that is, to open log files and new listen sockets. If this fails, it rolls back changes and continues to work with old configuration. If this succeeds, it starts new worker processes, and sends messages to old worker processes requesting them to shut down gracefully. Old worker processes close listen sockets and continue to service old clients. After all clients are serviced, old worker processes are shut down.

0 commit comments

Comments
 (0)