Iv. nginx service, architecture and Signal
(1) view nginx services
1.Netstat-antpCheck whether nginx is running on port 80:
2. View nginx processes in PS aux | grep nginx:
It is found that nginx has enabled two or more processes, one master process and one or more worker processes ).
From this we can see that nginx has a master process file for management and impact (such as disabling) 4 ~ 8 sub-processes. browser requests are handled by sub-processes.
The nginx worker model is as follows:
The main process is responsible for executing the following tasks:
- Read and verify configurations
- Create, bind, and close a socket
- Start, terminate, and maintain the number of work processes in the configuration
- Online Reconfiguration
- Online upgrade
- Re-open the log file
- Compile embedded Perl scripts
The worker process accepts and processes connections from clients, provides reverse proxy and filtering functions, and almost all other tasks that nginx can accomplish.
To monitor an nginx interface, the system administrator should monitor the worker because it reflects the daily operations of the Web server.
(2) nginx Signal Control
Nginx uses signals to control nginx stop and smooth restart. The main semaphores include:
Term, int |
Quick Shutdown |
Quit |
Graceful shutdown: closes the process after the request ends. |
Hup |
Configuration reload, start the new worker processes A new configuration gracefully shutdown the old worker Processes Change the configuration file, repeat the configuration file smoothly, and restart |
Usr1 |
Reopen the log files to repeat the log, which is useful in log Segmentation |
Usr2 |
Upgrade executable on the Fly smooth upgrade |
Winch |
Gracefully shutdown the worker processes calmly shut down the old process (with usr2 for upgrade) |
Example of signal usage:
The nginx process is disabled by using the int signal (kill-int process number ).
(This article was edited by Kayvan, the content is mainly collected on the internet, please indicate the source: http://www.cnblogs.com/kayvan)
Nginx high-performance Server installation, configuration, and O & M (4)-nginx service, architecture, and signal details