29

I can stop nginx server using nginx -s stop or nginx -s quit.

What is the difference?

3 Answers 3

38

Quit is a graceful shutdown. Nginx finishes serving the open connections before shutdown

Stop is a quick shutdown where is terminates in between serving the connection

http://wiki.nginx.org/CommandLine

1
  • I'm reading the link but it seems the difference between -s stop and -s quit isn't explained. It was necessary to additionally read the source code to confirm this answer is correct.
    – ynn
    Mar 19, 2023 at 4:35
7

-s stop terminates the nginx process immediately while -s quit does a graceful shutdown.

3

SIGQUIT causes nginx to break if it listens on Unix domain sockets. It will fail to clean up sockets, then immediately terminate on next invocation because it can't create sockets at paths which already exist.

SIGTERM causes nginx to shut down into a consistent state from which it can start back up. The daemon removes any Unix domain sockets, leaves all caches in a usable state, and so forth.

You basically never want to use QUIT.

1
  • The Unix domain sockets issue seems to be due to an open issue in nginx. However, if you aren't using this type of socket, it seems clear that the quit option is documented as the way to do a graceful exit.
    – RichVel
    Aug 15, 2019 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .