nginx 信號控制

2.nginx 信號控制

2.1 立即關閉進程
    命令:kill -INT 主進程號
    測試:
    [root@bogon nginx]# ps aux|grep nginx
    root      8499  0.0  0.0   3636   552 ?        Ss   04:41   0:00 nginx: master process ./sbin/nginx
    nobody    8500  0.0  0.0   3848   924 ?        S    04:41   0:00 nginx: worker process
    root      9009  0.0  0.0   4356   724 pts/0    S+   04:50   0:00 grep nginx
    [root@bogon nginx]# kill -INT 8499
    [root@bogon nginx]# ps aux|grep nginx
    root      9031  0.0  0.0   4356   724 pts/0    S+   04:55   0:00 grep nginx
2.2 請求結束後再關閉進程
    命令:kill -quit 主進程號 
    測試:
    [root@bogon nginx]# ps aux|grep nginx
    root      9034  0.0  0.0   3636   552 ?        Ss   04:55   0:00 nginx: master process ./sbin/nginx
    nobody    9035  0.0  0.0   3848   924 ?        S    04:55   0:00 nginx: worker process
    root      9038  0.0  0.0   4356   728 pts/0    S+   04:56   0:00 grep nginx
    [root@bogon nginx]# kill -quit 9034
    [root@bogon nginx]# ps aux|grep nginx
    root      9075  0.0  0.0   4356   724 pts/0    S+   05:01   0:00 grep nginx
2.3 改變配置文件,平滑的重讀新的配置文件
    命令:kill -hup 主進程號
    測試:
    [root@bogon nginx]# ps aux|grep nginx
    root      9079  0.0  0.0   3636   548 ?        Ss   05:01   0:00 nginx: master process ./sbin/nginx
    nobody    9080  0.0  0.0   3848   920 ?        S    05:01   0:00 nginx: worker process
    root      9083  0.0  0.0   4356   728 pts/0    S+   05:01   0:00 grep nginx
    [root@bogon nginx]# kill -hup 9079
    [root@bogon nginx]# ps aux|grep nginx
    root      9079  0.0  0.1   3780  1156 ?        Ss   05:01   0:00 nginx: master process ./sbin/nginx
    nobody    9085  0.0  0.0   3928  1012 ?        S    05:02   0:00 nginx: worker process
    root      9088  0.0  0.0   4356   724 pts/0    S+   05:02   0:00 grep nginx
2.4 重新啓動,並且平滑重新讀新的配置文件,不會關閉nginx
    命令:./sbin/nginx -s reload
    測試:
    [root@bogon nginx]# ps aux|grep nginx
    root      2276  0.0  0.0   3636   556 ?        Ss   01:41   0:00 nginx: master process ./sbin/nginx
    nobody    2277  0.0  0.1   3848  1204 ?        S    01:41   0:00 nginx: worker process
    root      2608  0.0  0.0   4356   752 pts/0    S+   02:26   0:00 grep nginx
    [root@bogon nginx]# ./sbin/nginx -s reload
    [root@bogon nginx]# ps aux|grep nginx
    root      2276  0.0  0.1   3780  1164 ?        Ss   01:41   0:00 nginx: master process ./sbin/nginx
    nobody    2611  0.0  0.0   3928  1020 ?        S    02:26   0:00 nginx: worker process
    root      2613  0.0  0.0   4356   752 pts/0    S+   02:26   0:00 grep nginx
2.5 關閉nginx
    命令:./sbin/nginx -s stop
    測試:
    [root@bogon nginx]# ps aux|grep nginx
    root      2276  0.0  0.1   3780  1164 ?        Ss   01:41   0:00 nginx: master process ./sbin/nginx
    nobody    2611  0.0  0.0   3928  1020 ?        S    02:26   0:00 nginx: worker process
    root      2613  0.0  0.0   4356   752 pts/0    S+   02:26   0:00 grep nginx
    [root@bogon nginx]# ./sbin/nginx -s stop
    [root@bogon nginx]# ps aux|grep nginx
    root      2626  0.0  0.0   4356   728 pts/0    S+   02:29   0:00 grep nginx
2.6 重讀配置文件
    命令:./sbin/nginx -s reopen
    測試:
    [root@bogon nginx]# ps aux|grep nginx
    root      2669  0.0  0.0   4356   748 pts/0    S+   02:32   0:00 grep nginx
    [root@bogon nginx]# ./sbin/nginx 
    [root@bogon nginx]# ps aux|grep nginx
    root      2671  0.0  0.0   3636   552 ?        Ss   02:32   0:00 nginx: master process ./sbin/nginx
    nobody    2672  0.0  0.0   3848   924 ?        S    02:32   0:00 nginx: worker process
    root      2675  0.0  0.0   4356   748 pts/0    S+   02:33   0:00 grep nginx
    [root@bogon nginx]# ./sbin/nginx -s reopen
    [root@bogon nginx]# ps aux|grep nginx
    root      2671  0.0  0.0   3636   604 ?        Ss   02:32   0:00 nginx: master process ./sbin/nginx
    nobody    2672  0.0  0.0   3848   988 ?        S    02:32   0:00 nginx: worker process
    root      2679  0.0  0.0   4356   724 pts/0    S+   02:33   0:00 grep nginx
2.7 進程結束後退出
    命令:./sbin/nginx -s quit
    測試:
    [root@bogon nginx]# ps aux|grep nginx
    root      2671  0.0  0.0   3636   604 ?        Ss   02:32   0:00 nginx: master process ./sbin/nginx
    nobody    2672  0.0  0.0   3848   988 ?        S    02:32   0:00 nginx: worker process
    root      2679  0.0  0.0   4356   724 pts/0    S+   02:33   0:00 grep nginx
    [root@bogon nginx]# ./sbin/nginx -s quit
    [root@bogon nginx]# ps aux|grep nginx
    root      2758  0.0  0.0   4356   724 pts/0    S+   02:47   0:00 grep nginx
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章