先附上错误信息:
1 (myblog) [email protected]:/home/uwsgi# service nginx status 2 ● nginx.service - A high performance web server and a reverse proxy server 3 Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) 4 Active: active (running) since Thu 2019-05-02 13:49:36 CST; 29s ago 5 Process: 17090 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS) 6 Process: 17101 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) 7 Process: 17094 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) 8 Main PID: 17103 (nginx) 9 Tasks: 2 10 Memory: 1.8M 11 CPU: 35ms 12 CGroup: /system.slice/nginx.service 13 ├─17103 nginx: master process /usr/sbin/nginx -g daemon on; master_process on 14 └─17104 nginx: worker process 15 16 May 02 13:49:36 Dapeng systemd[1]: Stopped A high performance web server and a reverse proxy server. 17 May 02 13:49:36 Dapeng systemd[1]: Starting A high performance web server and a reverse proxy server... 18 May 02 13:49:36 Dapeng systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument 19 May 02 13:49:36 Dapeng systemd[1]: Started A high performance web server and a reverse proxy server.
我的操作系统是ubuntu16.04,今天突然重启nginx后,发现给我报了一个502的错误,看了一下nginx的状态,里面有一个错误提示,就如同标题那样,遂Google,在一个歪果仁的个人博客中看到一个链接,解决了我的问题,我这里只做一个搬运工,有问题的小伙伴也可以参考。再附上ubuntu社区参考链接:bug for ubuntu
这个问题被当做bug来解决了,不过好在有大神解决,附上解决思路:
1 It seems to be a race between systemd and nginx. As if systemd was expecting the PID file to be populated before nginx had the time to create it. 2 3 Workaround: 4 5 mkdir /etc/systemd/system/nginx.service.d 6 printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf 7 systemctl daemon-reload
然后我们再重启一下就好了。
原文地址:https://www.cnblogs.com/cpl9412290130/p/10802434.html
时间: 2024-11-09 17:22:49