0

These are my NGINX processes:

root@ip-192-168-0-12:/etc/nginx/sites-enabled# ps aux | grep nginx
root      4758  0.0  0.0 102208  2780 ?        Ss   Jul25   0:00 nginx: master process /usr/sbin/nginx
www-data  5585  0.0  0.0 105868  7048 ?        S    Jul26  18:12 nginx: worker process
www-data  5586  0.0  0.0 105868  6972 ?        S    Jul26  18:07 nginx: worker process
www-data  5587  0.0  0.0 102208  2444 ?        S    Jul26   0:07 nginx: cache manager process
root     13190  0.0  0.0  12828  1008 pts/2    S+   20:13   0:00 grep --color=auto nginx

Now let's stop NGINX:

root@ip-192-168-0-12:/etc/nginx/sites-enabled# service nginx stop
nginx stop/waiting

Let's see if the processes still exist (omg they're still there):

root@ip-192-168-0-12:/etc/nginx/sites-enabled# ps aux | grep nginx
root      4758  0.0  0.0 102208  2780 ?        Ss   Jul25   0:00 nginx: master process /usr/sbin/nginx
www-data  5585  0.0  0.0 105868  7048 ?        S    Jul26  18:12 nginx: worker process
www-data  5586  0.0  0.0 105868  6972 ?        S    Jul26  18:08 nginx: worker process
www-data  5587  0.0  0.0 102208  2444 ?        S    Jul26   0:07 nginx: cache manager process
root     13230  0.0  0.0  12828  1008 pts/2    S+   20:16   0:00 grep --color=auto nginx

Then if I run service nginx start, the grep command would report exactly the same output - one master process, two workers and a cache manager.

What is happening here? Why cannot I just stop NGINX?

  • Post the contents of the file /etc/init.d/nginx. This is the script that starts and stops nginx. You can also address the nginx binary directly, use "man nginx" to work out it's options to start / stop. – Tim Aug 7 '16 at 20:50
1

It looks like service nginx stop sends a SIGTERM to the nginx process, which does not guarantee to stop it.

As suggested in the comment above, in your /etc/init.d/nginx can you check the content of the do_stop() function and see if you have:

start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PID --name $NAME. You may want to change the timeouts there (30, 5 in that example).

Also, check the outcome of the command nginx -s stop (fast shutdown) or nginx -s quit (graceful shutdown), and see if the processes mentioned above are still running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.