无法从文件/run/nginx.pid读取PID,但网站正常运行

问题描述 投票:0回答:1

当我检查Nginx的状态时

sudo service nginx status

Aug 01 12:35:07 iz2ze9wve43n2nyuvmsfx5z systemd[1]: Starting The nginx HTTP and reverse proxy server...
....
Aug 01 12:35:07 iz2ze9wve43n2nyuvmsfx5z systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
Aug 01 12:35:07 iz2ze9wve43n2nyuvmsfx5z systemd[1]: Started The nginx HTTP and reverse proxy server.

它报告“无法从文件/run/nginx.pid读取PID:无效的参数”

但是,我的网站正常运行,

我的custom_nginx.conf

server {
    listen 80;
    server_name *.example.com  39.105.51.**;
    charset utf-8;

    location / {
                uwsgi_read_timeout 30;
        uwsgi_pass 127.0.0.1:8200;
        include uwsgi_params;
   }

    location /media/ {
        alias /usr/share/nginx/html/;
                autoindex on;
   }
    location /static/ {
        alias /root/forum/dst_static/;
   }
}

我可以无误地访问www.example.com和39.105.51。**。我应该忽略它吗,什么样的错误正在等待着我?

django nginx uwsgi
1个回答
0
投票

[您似乎遇到了Nginx和systemd之间的已知竞争情况(错误)。这在低资源机器上似乎很普遍,尤其是当它们只有一个CPU时。

基本上发生的是,systemd期望在Nginx分叉之前填充PID文件。但是在资源不足的机器上,这是在Nginx fork有时间创建它之前发生的。因此,您会记录一个错误。

这不过是一个烦恼,因此,如果您不愿意,则无​​需为此做任何事情。如果您真的想停止它,则可以在Ubuntu bug report中找到解决方法:

mkdir /etc/systemd/system/nginx.service.d
printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" \
    > /etc/systemd/system/nginx.service.d/override.conf
systemctl daemon-reload

应用之后,尝试重新启动Nginx并查看它是否仍然存在。

systemctl restart nginx

您将不再收到该消息。

© www.soinside.com 2019 - 2024. All rights reserved.