zoukankan      html  css  js  c++  java
  • nginx学习(三):nginx的进程模型

    概述

    nginx 进程分为 master进程和work进程

    1.打开配置文件查看,这里我修改为2

    [root@xxx conf]# vim nginx.conf
    
    
    #user  nobody;
    worker_processes  2;
    
    

    2.重启,进入sbin 目录

    ./nginx -s reload
    
    

    3.nginx 常用命令

    ./nginx -s stop  # 停止
    ./nginx -s quit  # 退出
    ./nginx -s reload  #重启
    ./nginx -t #测试配置文件是否正确
    

    4.查看

    [root@xxx]# ps -ef|grep nginx
    root     18496     1  0 Dec14 ?        00:00:00 nginx: master process ./nginx
    nobody   28522 18496  0 09:49 ?        00:00:00 nginx: worker process
    nobody   28523 18496  0 09:49 ?        00:00:00 nginx: worker process
    root     28530 28497  0 09:50 pts/0    00:00:00 grep --color=auto nginx
    
    

    进程模型图

    这里是官网对于nginx reload的介绍

    nginx -s reload
    Once the master process receives the signal to reload configuration, it checks the syntax validity of the new configuration file and tries to apply the configuration provided in it. If this is a success, the master process starts new worker processes and sends messages to old worker processes, requesting them to shut down. Otherwise, the master process rolls back the changes and continues to work with the old configuration. Old worker processes, receiving a command to shut down, stop accepting new connections and continue to service current requests until all such requests are serviced. After that, the old worker processes exit.
    

    Nginx服务不会终止,主进程检查配置,应用配置的过程。主进程会启动一个新的工作进程处理新来的请求。主进程发送消息给老的工作进程,通知老的进程不在接受请求,处理完现有的请求后退出(优雅退出)

    总结

    nginx的每个进程都是独立的,相互之间是安全的。一个worker 宕机了,其它work还是继续工作,相互没有影响。这里我只是入门,更多关于这方面的知识还需要学习

  • 相关阅读:
    python3使用PyMysql连接mysql数据库
    MySQL知识总结
    python--正则表达式
    python之多线程
    python在windows和linux环境的进程对比及进程和进程之间的通信
    python基础之生成器(generator)
    python基础之动态添加属性和方法
    [STM32F1] 【转】STM32驱动MPU6050
    51单片机怎么使用MPU6050读取角度值程序 ??
    stm32f10x_lib.h
  • 原文地址:https://www.cnblogs.com/zhenghengbin/p/12076120.html
Copyright © 2011-2022 走看看