zoukankan      html  css  js  c++  java
  • nginx的问题?

    现象:

    nginx restart 超时
    nginx stop之后,80端口仍然被占用
    在 kill调进程之后再启动
    查看 systemctl status nginx

    systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
    

    百度结果:

    Failed to read PID from file

    因为 nginx 启动需要一点点时间,而 systemd 在 nginx 完成启动前就去读取 pid file
    造成读取 pid 失败
    
    解决方法很简单,让 systemd 在执行 ExecStart 的指令后等待一点点时间即可
    如果你的 nginx 启动需要时间更长,可以把 sleep 时间改长一点
    
    mkdir -p /etc/systemd/system/nginx.service.d
    printf "[Service]
    ExecStartPost=/bin/sleep 0.1
    " > /etc/systemd/system/nginx.service.d/override.conf
    
    然后
    systemctl daemon-reload
    systemctl restart nginx.service
    

    结果

    [root@yumsources yum]# systemctl status nginx
    ● nginx.service - The nginx HTTP and reverse proxy server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
      Drop-In: /etc/systemd/system/nginx.service.d
               └─override.conf
       Active: active (running) since Sat 2020-06-27 16:50:21 CST; 50s ago
      Process: 24397 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
      Process: 24393 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
      Process: 24390 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
      Process: 24389 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
     Main PID: 24396 (nginx)
       CGroup: /system.slice/nginx.service
               ├─24396 nginx: master process /usr/sbin/nginx
               └─24398 nginx: worker process
    
    Jun 27 16:50:21 yumsources systemd[1]: Starting The nginx HTTP and reverse proxy server...
    Jun 27 16:50:21 yumsources nginx[24390]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    Jun 27 16:50:21 yumsources nginx[24390]: nginx: configuration file /etc/nginx/nginx.conf test is successful
    Jun 27 16:50:21 yumsources systemd[1]: Started The nginx HTTP and reverse proxy server.
    
    
  • 相关阅读:
    Hz赫兹的定义
    NetCore 迅速接入微信支付+支付宝支付 payLink C# 交差并集
    C# 生产随机数 --几乎可以做到不重复
    Spark MLib完整基础入门教程
    (转)Scrapy 教程
    (转)python自顶向下设计步骤_python实现自顶向下,自底向上
    (转)scrapy架构图与执行流程
    (转)Python:字典(zip, dict)
    (转)APUE第13章 守护进程Deameon
    (转)Python开发指南
  • 原文地址:https://www.cnblogs.com/leaderjs/p/13198856.html
Copyright © 2011-2022 走看看