为什么不停止 nginx 服务器杀死与之相关的进程?

ber*_*436 5 networking process services nginx

当我在 ubuntu 12.04 上像这样停止 nginx 时,出现以下错误:

$ sudo service nginx stop
Stopping nginx: nginx.
$sudo service nginx start
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Run Code Online (Sandbox Code Playgroud)

我必须用来修复它。为什么停止服务不杀死nginx进程?这令人困惑!

mr_*_*ron 6

默认情况下,start-stop-daemon 将 SIGTERM 发送到 nginx 进程。它不保证停止过程。修复:在/etc/init.d/nginx“停止”字符串部分的文件更改中

start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
Run Code Online (Sandbox Code Playgroud)

start-stop-daemon --stop --retry=TERM/30/KILL/5 --quiet --pidfile /var/run/$NAME.pid \
Run Code Online (Sandbox Code Playgroud)

如果 SIGTERM 不停止进程,该修复程序将发送 SIGKILL (kill -9)。

并请确保,pid-file pid /var/run/nginx.pid;in/etc/nginx/nginx.conf和 path --pidfile /var/run/$NAME.pidin/etc/init.d/nginx的路径相同。