Skip to content

Nginx supported signal list

homepage-banner

Introduction

Nginx is an open-source, high-performance web server widely used for its speed, stability, and low resource utilization. It is designed to handle large numbers of simultaneous connections and requests. Nginx is also equipped with a set of signals that can be used to control its behavior. Signals are a way to communicate with running processes on a Unix-like system. In this blog post, we will discuss the supported signal list in Nginx and how to use them.

List of Supported Signals in Nginx

Here are the supported signals in Nginx:

  1. TERM - This signal is used to gracefully shut down the Nginx server. It allows the server to finish serving current requests before shutting down.
  2. QUIT - This signal is used to gracefully shut down the Nginx server. It is similar to the TERM signal, but it also generates a core dump file.
  3. HUP - This signal is used to reload the Nginx configuration file. When you make changes to the configuration file, you can send this signal to Nginx to read the new configuration file and apply the changes.
  4. USR1 - This signal is used to reopen the log files. When you rotate the log files, you can send this signal to Nginx to reopen the log files without restarting the server.
  5. USR2 - This signal is used to upgrade the Nginx server binary. When you want to upgrade Nginx to a new version, you can send this signal to Nginx to start a new process with the new binary and gracefully shut down the old process.
  6. WINCH - This signal is used to gracefully shut down worker processes. When you want to stop worker processes without interrupting active connections, you can send this signal to Nginx to stop accepting new connections and finish serving current connections before shutting down the worker processes.

How to Use Signals in Nginx

To send a signal to a running Nginx process, you can use the kill command followed by the process ID (PID) of the Nginx process. For example, to gracefully shut down the Nginx server, you can use the following command:

kill -TERM <nginx-pid>

Replace <nginx-pid> with the actual PID of the Nginx process. You can find the PID of the Nginx process using the ps command. For example:

ps aux | grep nginx

This will display a list of all Nginx processes running on the system along with their PIDs.

Conclusion

Knowing the supported signal list in Nginx is essential for managing and controlling the behavior of the server. Signals can be used to gracefully shut down the server, reload the configuration file, reopen the log files, upgrade the server binary, and stop worker processes. By using signals, you can ensure that the server behaves as expected and avoid any disruptions to your website or application.

Leave a message