无法停止 nginx 服务

无法停止 nginx 服务

我们在 systemd 中运行 nginx(在端口 8080 上),CentOS 7.7但无法停止它 - 没有错误,它只是继续运行或重生。

我们已经尝试过了sudo systemctl stopsudo systemctl disable但是kill它仍然继续运行。

Nov 11 13:04:18 myhost systemd[1]: Started The Gateway - Nginx.
[myuser@myhost gateway]$ sudo systemctl stop gateway
[myuser@myhost gateway]$ sudo systemctl status gateway
gateway.service - The Gateway - Nginx
   Loaded: loaded (/usr/lib/systemd/system/gateway.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Mon 2019-11-11 13:04:18 CET; 6min ago
  Process: 20988 ExecStart=/usr/sbin/nginx -c /prg/nginx/conf/gateway.conf (code=exited, status=0/SUCCESS)
  Process: 20985 ExecStartPre=/usr/sbin/nginx -t -c /prg/nginx/conf/gateway.conf (code=exited, status=0/SUCCESS)
  Process: 20983 ExecStartPre=/usr/bin/rm -f /daten/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 20988 (code=exited, status=0/SUCCESS)
    Tasks: 2
   Memory: 1.6M
   CGroup: /system.slice/gateway.service
           ├─20990 nginx: master process /usr/sbin/nginx -c /prg/nginx/conf/gateway.conf
           └─20991 nginx: worker process

Nov 11 13:04:18 myhost systemd[1]: Starting The Gateway - Nginx...
Nov 11 13:04:18 myhost node-gateway[20985]: nginx: the configuration file /prg/nginx/conf/gateway.conf syntax is ok
Nov 11 13:04:18 myhost node-gateway[20985]: nginx: configuration file /prg/nginx/conf/gateway.conf test is successful
Nov 11 13:04:18 myhost systemd[1]: Started The Gateway - Nginx.

禁用并停止

[myuser@myhost gateway]$ sudo systemctl disable gateway
Removed symlink /etc/systemd/system/multi-user.target.wants/gateway.service.
[myuser@myhost gateway]$ sudo systemctl stop gateway

仍在运行

[myuser@myhost gateway]$ sudo systemctl status gateway
gateway.service - The Gateway - Nginx
   Loaded: loaded (/usr/lib/systemd/system/gateway.service; disabled; vendor preset: disabled)
   Active: inactive (dead) since Mon 2019-11-11 13:04:18 CET; 6min ago
 Main PID: 20988 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/gateway.service
           ├─20990 nginx: master process /usr/sbin/nginx -c /prg/nginx/conf/gateway.conf
           └─20991 nginx: worker process

Nov 11 13:04:18 myhost systemd[1]: Starting The Gateway - Nginx...
Nov 11 13:04:18 myhost node-gateway[20985]: nginx: the configuration file /prg/nginx/conf/gateway.conf syntax is ok
Nov 11 13:04:18 myhost node-gateway[20985]: nginx: configuration file /prg/nginx/conf/gateway.conf test is successful
Nov 11 13:04:18 myhost systemd[1]: Started The Gateway - Nginx.
[myuser@myhost gateway]$ ps -auxf | grep nginx
myuser    21846  0.0  0.0 112684   696 pts/0    S+   13:11   0:00  |           \_ grep --color=auto nginx
root      20990  0.0  0.0  59080  1388 ?        Ss   13:04   0:00 nginx: master process /usr/sbin/nginx -c /prg/nginx/conf/gateway.conf
nginx     20991  0.0  0.0  61272  2708 ?        S    13:04   0:00  \_ nginx: worker process
[myuser@myhost gateway]$ sudo lsof -i -P -n | grep 8080
node       1313              root   20u  IPv4 429747      0t0  TCP 127.0.0.1:51580->127.0.0.1:8080 (ESTABLISHED)
node       1313              root   21u  IPv4 432203      0t0  TCP 127.0.0.1:51640->127.0.0.1:8080 (ESTABLISHED)
node       1316 serviceuser   19u  IPv4 332198      0t0  TCP 172.25.24.45:57328->172.25.24.20:8080 (ESTABLISHED)
node       1316 serviceuser   21u  IPv4 318233      0t0  TCP 172.25.24.45:57260->172.25.24.20:8080 (ESTABLISHED)
nginx     20990              root    6u  IPv4 430360      0t0  TCP *:8080 (LISTEN)
nginx     20991             nginx    3u  IPv4 430473      0t0  TCP 127.0.0.1:8080->127.0.0.1:51580 (ESTABLISHED)
nginx     20991             nginx    6u  IPv4 430360      0t0  TCP *:8080 (LISTEN)
nginx     20991             nginx   25u  IPv4 432204      0t0  TCP 127.0.0.1:8080->127.0.0.1:51640 (ESTABLISHED)

答案1

 Active: inactive (dead) since Mon 2019-11-11 13:04:18 CET; 6min ago

对我来说,它看起来是不活动的(=死了、停止了,不管你喜欢怎么称呼它)?

编辑:看来该过程可能仍在进行中:

root      20990  0.0  0.0  59080  1388 ?        Ss   13:04   0:00 nginx: master process /usr/sbin/nginx -c /prg/nginx/conf/gateway.con

您可以尝试使用 kill 命令手动将其杀死,如果 SIGTERM 不起作用,请尝试 SIGKILL

kill -SIGTERM <process id, 20990 in this case>

相关内容