nginx singal

1 HUP

如果修改./nginx/conf/nginx.conf,nginx不重启不会重新加载新的conf。例如:我修改默认的location / ,把ab.html放在第一访问序列。不重启,则仍是访问index.html

location / {
    root   html;
    index  ab.html index.html index.htm;
}

重启nginx之前,要检查nginx.conf语法是否正确

 -t            : test configuration and exit
 -c filename   : set configuration file (default: conf/nginx.conf)
[root@nginx2 ~]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

 然后用HUP信号来平滑重启nginx,这样就会加载新的配置文件

[root@nginx2 ~]# kill -HUB `cat /usr/local/nginx/logs/nginx.pid`

 再访问ip,就会显示ab.html。

2 USR1

nginx运行时打开访问日志文件,如果我用mv给这个文件改名,由于文件特性,是没有用的。nginx还是根据文件描述符打开那个文件,往里面写日志。

这样就无法进行日志分割。

[root@nginx2 logs]# lsof| grep nginx| grep log    
nginx     45792                 root    2w      REG              253,0      4862   33683908 /usr/local/nginx/logs/error.log
nginx     45792                 root    8w      REG              253,0  17896102   33683910 /usr/local/nginx/logs/nginx_access.log
nginx     45792                 root    9w      REG              253,0      4862   33683908 /usr/local/nginx/logs/error.log

 USR1信号量就是使nginx重读日志文件。

[root@nginx2 logs]# kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`

 这时发现,nginx新创建了一个access.log文件,并往里面写日志。

[root@nginx2 logs]# ll
total 17500
-rw-r--r--. 1 www  root      333 Jun 21 21:53 access.log
-rw-r--r--. 1 www  root      666 Jun 21 21:52 access.log.xx

3 USR2

平滑升级

--end--

-s signal     : send signal to a master process: stop, quit, reopen, reload

 ./nginx -s signal 功能就是发送信号量

stop是杀进程

quit是优雅退出

reopen是重读日志文件

reload是重载配置

猜你喜欢

转载自www.cnblogs.com/jabbok/p/9211113.html