这些是我的NGINX进程:
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
现在让我们停止NGINX:
root@ip-192-168-0-12:/etc/nginx/sites-enabled# service nginx stop nginx stop/waiting
让我们看看过程是否仍然存在( omg他们仍然存在 ):
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
然后,如果我运行service nginx start
, grep
命令将报告完全相同的输出 – 一个主进程,两个工人和一个cachingpipe理器。
这里发生了什么? 为什么我不能停止NGINX?
它看起来像service nginx stop
向nginx进程发送一个SIGTERM,它不保证停止它。
正如上面的注释中所build议的那样,在/etc/init.d/nginx
可以检查do_stop()
函数的内容,看看是否有:
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PID --name $NAME
。 您可能想要更改那里的超时(在这个例子中是30,5)。
另外,请检查命令nginx -s stop
(fast shutdown)或nginx -s quit
(正常closures)的结果,并查看上述过程是否仍在运行。