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


    先附上错误信息:

     1 (myblog) root@Dapeng:/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]
    ExecStartPost=/bin/sleep 0.1
    " > /etc/systemd/system/nginx.service.d/override.conf
    7  systemctl daemon-reload

    然后我们再重启一下就好了。

  • 相关阅读:
    问题 A: C#抽象类Vehicles
    最短路练习
    BFS
    poj 1083 Moving Tables
    组合数
    hdu 1443 Joseph【约瑟夫环】
    poj 2449 Remmarguts' Date【第K短路】
    hdu 1695 GCD 【莫比乌斯函数】
    hdu 2178 猜数字
    bzoj 2440 完全平方数 【莫比乌斯函数】
  • 原文地址:https://www.cnblogs.com/cpl9412290130/p/10802434.html
Copyright © 2020-2023  润新知