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

Docker deploys net5 program to achieve cross-platform functions

Deployment environment: docker container, liunx s...

Summary of the data storage structure of the nginx http module

Starting from this section, we will explain the i...

How to fix abnormal startup of mysql5.7.21

A colleague reported that a MySQL instance could ...

Do you know the common MySQL design errors?

Thanks to the development of the Internet, we can...

Nginx configuration to achieve multiple server load balancing

Nginx load balancing server: IP: 192.168.0.4 (Ngi...

Why is there this in JS?

Table of contents 1. Demand 2. Solution 3. The fi...

Detailed explanation of the use of base tag in HTML

In requireJS, there is a property called baseURL....

Implementation of Nginx filtering access logs of static resource files

Messy log Nginx in daily use is mostly used as bo...

The easiest way to install MySQL 5.7.20 using yum in CentOS 7

The default database of CentOS7 is mariadb, but m...

Summary of some tips for bypassing nodejs code execution

Table of contents 1. child_process 2. Command exe...

Problems with nodejs + koa + typescript integration and automatic restart

Table of contents Version Notes Create a project ...

XHTML: Frame structure tag

Frame structure tag <frameset></frameset...

How to simply encapsulate axios in vue

Inject axios into Vue import axios from 'axio...