nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument解决

先附上错误信息:

 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

nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument解决的相关文章

Failed to issue method call: Unit mysql.service failed to load: No such file or directory的解决办法

Failed to issue method call: Unit mysql.service failed to load: No such file or directory的解决办法 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs 1.软件环境: OpenSUSE 13.1 x64 MySQL 5.6.20 x64 2.采用RPM包安装MySQL 5.6.20 # rpm -ivh MySQL-server-5.6.20-1.sles11.x8

Failed to issue method call: Unit mysql.service failed to load: No such file or directory解决的方式

Failed to issue method call: Unit mysql.service failed to load: No such file or directory解决的方式 作者:chszs.转载需注明.博客主页:http://blog.csdn.net/chszs 1.软件环境: OpenSUSE 13.1 x64 MySQL 5.6.20 x64 2.採用RPM包安装MySQL 5.6.20 # rpm -ivh MySQL-server-5.6.20-1.sles11.x8

nginx启动报错:Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' fo

一.背景 这个错误在重启nginx或者启动nginx的时候,经常会出现.我之前也一直认为出现这个错误是因为有程序占用了nginx的进程.但是知其然不知其所以然.每次报错都有点懵逼,所以这边一步步排查错误,做个记录. 二.排错过程 1.按照提示 //按照提示,执行此命令,查看错误原因 systemctl status nginx.service 由报错信息可知,nginx绑定80端口失败.详细错误请输入 -l 继续查看 2.继续跟踪错误 //查看错误的详情 systemctl status ngi

nginx提示Job for nginx.service failed because the control的问题

启动nginx时就报错!Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. 墙内外找了一圈找了一圈终于还是在墙外找到答案了.. 现在假设你是这样操作的:你修改了/etc/nginx/conf.d/default.con

Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.

可能的原因: 1.http://blog.sina.com.cn/s/blog_4692ea0a0101jqhz.html 2.http://diag.5ustore.com/proxy/index.php?url=1J1h12y31F1b1918yLyByU1FyNyjyD101z1612yo1C1cyc1sy3yc1yyN161611yY0RyiyiyJyY1hymylyj1hyL1gyS1LyWyR1Myhyk0VyMylyvyg0j1j1D1F1k18171r1P1HyuyI1DyNyB

Nginx:Job for nginx.service failed

执行 service nginx start或者restart命令出现下面错误 [[email protected] ~]# service nginx restart Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details

[ISSUE] [Centos] Centos Start Nginx Show: Failed to start nginx.service:unit not found

CMD Line:systemctl start nginx.serviceFailed to start nginx.service: Unit not found. Solution: 1.vim /etc/init.d/nginx #!/bin/sh # nginx - this script starts and stops the nginx daemin # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server,

CentOS 7 防火墙 出现Failed to start iptables.service: Unit iptables.service failed to load

错误信息如下: [root]# service iptables start Redirecting to /bin/systemctl start iptables.service Failed to start iptables.service: Unit iptables.service failed to load: No such file or directory.解决方法如下: 一直用CentOS 6 习惯了,一下没适应过来.防火墙配置后执行service iptables sav

解决 RHEL 7/ CentOS 7/Fedora 出现Unit iptables.service failed to load

防火墙配置后执行service iptables save 出现"Failed to restart iptables.service: Unit iptables.service failed to load: No such file or directory."错误,在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理,当然你可以还原传统的管理方式.或则使用新的命令进行管理. 假如采用传统请执行一下命令: systemctl stop firewall