This is a follow up on my previous articles on using the NGINX server. On my older wordpress blog, I highlighted the steps involved in installing and getting NGINX running on your development environment. Here, I would like to share how I manage my nginx processes in the same development environment.
If you use Apache through the Passenger gem, you could type something like this to restart the server gracefully:
sudo apachectl graceful
and to shutdown:
sudo apachectl shutdown
To do the same in nginx, you would need to type the following:
sudo kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`
What the above command does is to do a graceful shutdown of the master process, which would in turn call shutdown on the worker processes. Note the backticks and the cat command. What it does is to run the cat command on the pid file to grab the pid value and pass it to the QUIT signal.
If you need to reload the server after making changes to the configuration file (i.e. nginx.conf), just do:
sudo kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
More command line options can be found on the NGINX wiki, which even details the sequence of events when signals are sent as well as how to upgrade an entire nginx executable on the fly with 0 downtime.
Sweet!