Ubuntu nginx.service的作业失败,因为超过了超时时间

Ubuntu nginx.service的作业失败,因为超过了超时时间,ubuntu,nginx,systemd,Ubuntu,Nginx,Systemd,我使用RTMP作为自定义版本构建了nginx 我使用上建议的以下设置创建了etc/systemd/system/nginx.service,并使用我的自定义构建位置进行了轻微编辑 [Unit] Description=The NGINX HTTP and reverse proxy server After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile

我使用RTMP作为自定义版本构建了nginx

我使用上建议的以下设置创建了
etc/systemd/system/nginx.service
,并使用我的自定义构建位置进行了轻微编辑

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/home/ubuntu/nginx_working/nginx-1.14.0/objs/nginx -t
ExecStart=/home/ubuntu/nginx_working/nginx-1.14.0/objs/nginx
ExecReload=/home/ubuntu/nginx_working/nginx-1.14.0/objs/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
User=root
PrivateTmp=true
TimeoutStartSec=0

[Install]
WantedBy=multi-user.target
如果我只是从终端启动nginx,nginx工作正常

使用systemd eg
systemctl start nginx
,终端会挂起一段时间,在此期间nginx工作正常,但大约30秒后,我获得了nginx的
作业。由于超时,服务失败。

此超时为false,因为nginx在这30秒内运行正常。我不确定为什么它无法检测到nginx已启动?

自己找到了解决方案。 由于某些原因,出现以下错误
无法打开PID文件/run/nginx.PID

如解决方案中所述,将配置中的PID移动到日志位置
/usr/local/nginx/logs