1. 程式人生 > >nginx進程和實時控制

nginx進程和實時控制

重新 time use mat cut .org owin 操作系統 ted

原文地址:http://nginx.com/resources/admin-guide/processes-and-runtime-control/

Processes and Runtime Control
進程和實時控制


This section describes the processes NGINX starts at run time and how to control them.

本文討論Nginx開始執行時的進程以及怎樣控制這些進程。

Master and Worker Processes
主進程和工作進程

NGINX has one master process and one or more worker processes. If caching

is enabled, the cache loader and cache manager processes will also run.

Nginx 有一個主進程和至少一個工作進程。假設緩存開啟,緩存載入器和緩存管理器進程也會執行。

The main purpose of the master process is to read and evaluate configuration files, as well as, maintaining worker processes.

主進程的主要工作就是讀取和評估配置文件,同一時候操作工作進程。

The Worker processes do the actual processing of requests. NGINX relies on OS-dependent mechanisms to efficiently distribute requests among worker processes. The number of worker processes is defined in the nginx.conf file and may be fixed for a given configuration or automatically adjusted to the number of available CPU cores (see worker_processes

).

工作進程直接處理請求。Nginx依賴操作系統機制均衡地把請求分發到各工作進程。工作進程和數量在nginx.conf文件裏定義,當然也能夠設置為自己主動來依據可用的CPU內核進程調整(見worker_processes)。

Controlling nginx
控制Nginx

To reload your configuration, you can stop, or restart nginx, or send signals to the master process. A signal can be sent by running the NGINX executable with the -s parameter.

要重加載入你的配置。你能夠停止,或者重新啟動Nginx。或者發送一個信號給主進程。執行nginx並帶著-s參數能發送一個信號給Nginx主進程。

nginx -s signal

When us -s the signal parameter may be one of the following:

-s 後接的信號參數為下面當中一個:

  • stop — fast shutdown 高速關閉
  • quit — graceful shutdown 優雅關閉
  • reopen — reopening the log files 重新啟動日誌文件
  • reload — reloading the configuration file 重載入配置文件

A signal can also be sent directly to the master process with the use of the kill utility. The process ID of the master process is written, by default, to the nginx.pid file, which is located in the /usr/local/nginx/logs or /var/run directory.

一個信號也可能直接使用kill工具發送給主進程。須要用到主進程的進程號,默認的在nginx.pid文件裏,該文件可能放在/usr/local/nginx/logs或者/var/run文件夾下。

You can read more about advanced signals like log file reopening and live binary upgrades in the Controlling NGINX documentation.

你能夠在 Controlling NGINX documentation 裏找到很多其它的可用信號,比如重新啟動日誌文件和執行時二進制升級。

nginx進程和實時控制