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

Detailed example of using useState in react

useState useState adds some internal state to a c...

Windows Server 2016 Quick Start Guide to Deploy Remote Desktop Services

Now 2016 server supports multi-site https service...

Summary of commonly used time, date and conversion functions in Mysql

This article mainly summarizes some commonly used...

MySQL daily statistics report fills in 0 if there is no data on that day

1. Problem reproduction: Count the total number o...

MySQL uses the truncate command to quickly clear all tables in a database

1. Execute the select statement first to generate...

A simple example of mysql searching for data within N kilometers

According to the coefficient of pi and the radius...

Javascript design pattern prototype mode details

Table of contents 1. Prototype mode Example 1 Exa...

How to compare two database table structures in mysql

During the development and debugging process, it ...

CSS Sticky Footer Implementation Code

This article introduces the CSS Sticky Footer imp...

Five ways to implement inheritance in js

Borrowing Constructors The basic idea of ​​this t...

Solution to 1449 and 1045 exceptions when connecting to MySQL

Solution to 1449 and 1045 exceptions when connect...

Linux uses if to determine whether a directory exists.

How to use if in Linux to determine whether a dir...

Docker packages the local image and restores it to other machines

1. Use docker images to view all the image files ...

Detailed explanation of galera-cluster deployment in cluster mode of MySQL

Table of contents 1: Introduction to galera-clust...