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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值