Reputation: 603
I made a custom build of nginx with RTMP as outlined here.
I created etc/systemd/system/nginx.service
with the following settings as suggested on nginx website, slightly edited with my custom build location.
[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
If I just start nginx from terminal, nginx works fine.
Using systemd eg systemctl start nginx
, terminal hangs for a bit, during this time nginx is working fine, however after about 30 seconds I get Job for nginx.service failed because a timeout was exceeded.
This timeout is false as nginx was running just fine during these 30s. I am unsure why it fails to detect that nginx has started?
Upvotes: 1
Views: 4293
Reputation: 603
Found the solution myself.
For some reason, following error occurs Can't open PID file /run/nginx.pid
As mentioned in AskUbuntu the solution was to move my PID in the config to the logs location /usr/local/nginx/logs
Upvotes: 3