Nginx signal control

Nginx signal control

Introduction to Nginx

Nginx is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server. Nginx was developed by the Russian site Rambler.ru, and official tests show that Nginx can support 50,000 concurrent connections.

Nginx official website: http://nginx.org

This article mainly explains how to control Nginx after it is running so that it can be stopped or restarted.

// Start and stop nginx
Current directory: /usr/local/bin/nginx
start up:
./sbin/nginx
stop:
kill -INT master host process number

Nginx semaphore

Nginx is mainly controlled by semaphores. The main process number is written to the file nginx.pid by default. The name of the file can be modified by modifying the configuration file nginx.conf.

The signals supported by the Nginx master process are as follows:

How to use semaphore

Specific explanation

TERM,INT: kill -TERM (INT) nginx main process number or kill -TERM (INT)

`cat /usr/local/nginx/logs/nginx.pid `, the nginx process is immediately closed and cannot fully process the requests of the users who are using nginx. This is equivalent to /usr/local/nginx -s stop

QUIT:kill -QUIT nginx main process number gracefully closes the nginx process, and closes the nginx process after processing all user requests that are using nginx, which is equivalent to /usr/local/nginx -s quit

HUP:kill -HUP nginx main process number The nginx process is not closed, but the configuration file is reloaded. Equivalent to /usr/local/nginx -s reload

USR1:kill -USR1 nginx main process number can reread the log without shutting down the nginx process. This command can be used for scheduled log backup of nginx, which is useful for splitting by time intervals such as month/day

USR2:kill -USR2 nginx main process number When the version of nginx needs to be upgraded, you can upgrade nginx without stopping nginx

WINCH:kill -WINCH nginx main process number cooperates with USR2 to upgrade nginx and gracefully close the process of the old version of nginx.

By using these Nginx semaphores, you can control nginx log segmentation and nginx upgrades without shutting down the process. As I gradually get to know Nginx more deeply, I feel that Nginx can achieve such amazing results with only 50,000 lines of code. I really admire it!

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Detailed explanation of nginx signal set case
  • Introduction to Nginx log management
  • Detailed explanation of CentOS configuration of Nginx official Yum source
  • Install multiple versions of PHP for Nginx on Linux
  • Detailed tutorial on installing PHP and Nginx on Centos7
  • A universal nginx interface to implement reverse proxy configuration
  • Solve the problem of refreshing blank when deploying Vue project nginx to non-root directory
  • How to install Nginx and configure multiple domain names
  • When Nginx is turned on, the port is occupied and prompts: Address already in use
  • Solution to the problem that docker nginx cannot be accessed after running
  • How to redirect to https through nginx load balancing

<<:  Example code of layim integrating right-click menu in JavaScript

>>:  Tutorial on installing MySQL 5.6 on CentOS 6.5

Recommend

HTML Language Encyclopedia

123WORDPRESS.COM--HTML超文本标记语言速查手册<!-- --> !D...

Front-end advanced teaching you to use javascript storage function

Table of contents Preface Background Implementati...

Why MySQL database avoids NULL as much as possible

Many tables in MySQL contain columns that can be ...

How to set background color and transparency in Vue

Background color and transparency settings As sho...

Vue+echarts realizes stacked bar chart

This article shares the specific code of Vue+echa...

How to install jupyter in docker on centos and open ports

Table of contents Install jupyter Docker port map...

Detailed process of using vmware to test PXE batch installation server

Table of contents 1. Preparation 1. Prepare the e...

How to move a red rectangle with the mouse in Linux character terminal

Everything is a file! UNIX has already said it. E...

Deeply understand how nginx achieves high performance and scalability

The overall architecture of NGINX is characterize...

How to clean up the disk space occupied by Docker

Docker takes up a lot of space. Whenever we run c...

CentOS8 - bash: garbled characters and solutions

This situation usually occurs because the Chinese...

A Brief Discussion on the Navigation Window in Iframe Web Pages

A Brief Discussion on the Navigation Window in If...

Douban website's method for making small changes to website content

<br />Reading is a very important part of th...

Use js to write a simple snake game

This article shares the specific code of a simple...