Follow these 3 steps to gracefully stop and start Nginx without losing any queries. It works like a charm.
- Test new configuration is correct
nginx -t
- Find the Pid
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
- And kill it. Meanwhile, new configuration is already effective.
kill -HUP ????
(replace ???? with the Pid given in step 2)