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

MySQL 5.7.18 free installation version configuration tutorial

MySQL 5.7.18 free installation version installati...

MySql sets the specified user database view query permissions

1. Create a new user: 1. Execute SQL statement to...

Will this SQL writing method really cause the index to fail?

Preface There are often some articles on the Inte...

How to transfer files between Docker container and local machine

To transfer files between the host and the contai...

Summary of MySQL commonly used type conversion functions (recommended)

1. Concat function. Commonly used connection stri...

How to encapsulate axios request with vue

In fact, it is very simple to encapsulate axios i...

Detailed explanation of Nginx access restriction configuration

What is Nginx access restriction configuration Ng...

JS practical object-oriented snake game example

Table of contents think 1. Greedy Snake Effect Pi...

Core skills that web front-end development engineers need to master

The content involved in Web front-end development...

CentOS 7 method to modify the gateway and configure the IP example

When installing the centos7 version, choose to co...

How to view and clean up Docker container logs (tested and effective)

1. Problem The docker container logs caused the h...

Vue implements multi-tab component

To see the effect directly, a right-click menu ha...