Nginx multi-process model implementation details analysis
Foreword: “ Server programs usually control the work of the server through corresponding configuration files. In many cases, the configuration file will be modified frequently. When making it take effect, we hope that the program will not be restarted and the normal service of the server will not be affected. So the so-called “hot loading” of configuration files has become a very important function, and in this regard, nginx has set a very good example for us, which is worth learning and learning from. analyze: “ When nginx is in normal service, we execute ./nginx in the program directory of nginx ?sreload, to reload the configuration file. The function of -s is to send a signal to the master process. In addition to the reload function, stop, reopen, etc. can also be used. Specifically, you can view it through -h. When executing ./nginx ?s After reload, save the “reload” string through ngxs_signal, and then pass it through ngx_signal_process To send a signal to the currently running nginxmaster process. if (ngx_signal) { “ return ngx_signal_process(cycle, ngx_signal); } By reading the code, we can see that sending a signal to the currently running nginx process is actually restarting a copy of nginx,…