table of Contents
With several years of Nginx
consistent without questioning the difference between the two of them I am always thought restart command, but also when used with nginx -s reload
more. This period of time is a Docker
toss Nginx
, so I looked at Nginx
the official documents, suddenly found nginx -s
using the command.
Official document: https://nginx.org/en/docs/beginners_guide.html
1. Grammar
nginx -s signal
signal
The value of is as follows:
stop
fast shutdown, fast stop nginx
quit
: graceful shutdown, no longer accept new requests, stop after the request being processed is completed (graceful shutdown)
reload
: reloading the configuration file, reload the configuration file
reopen
: reopening the log files, re-write the log files
2. The difference between the two
nginx -s reload
(Hot reload): The Nginx
service will not be terminated, use the main process to check the configuration 如果配置文件语法正确,则主进程会启动一个新的工作进程处理新来的请求
. The main process sends a message to the original worker process, notifying that the old process is not accepting requests, and exits after processing the existing request (graceful exit); if the syntax is incorrect, the old process continues to process the request.
service nginx restart
(Restart): during the execution of this command is as follows, nginx -s stop
-> nginx
first Nginx
quick stop (equal to service nginx stop
), and then perform the startup commands (equivalent to service nginx start
) start time will cause a brief interruption in service; if the configuration file syntax error, The problem is big, it may cause a longer interruption, and it may cause a large downtime.
3. Matters needing attention
-
If the environment is formally required to modify the configuration file, first look at the original configuration file backup, and then making modifications; after the first modification is completed by
nginx -t
whether an error check the configuration file, if not, thennginx -s reload
heat load. -
If asked to stop
Nginx
or releaseNginx
a resource that we useservice nginx stop
orservice nginx restart
command, or are generally usednginx -s reload
.
Personal blog: http://roc.havemail.cn/archives/892.html