[systemd-devel] How to run forking daemon with systemd in correct way, without errors?
Clemens Gruber
clemens.gruber at pqgruber.com
Wed Nov 22 22:35:26 UTC 2017
Hi,
On Thu, Nov 23, 2017 at 12:02:01AM +0200, Gena Makhomed wrote:
> On 22.11.2017 23:27, Reindl Harald wrote:
>
> > > I am use nginx web server (http://nginx.org/) with systemd.
> > > But I see errors in /var/log/messages when running nginx:
> > >
> > > systemd: Starting nginx - high performance web server...
> > > systemd: Failed to read PID from file /var/run/nginx.pid: Invalid
> > > argument
> > > systemd: Started nginx - high performance web server.
> > >
> > > systemd: Starting nginx - high performance web server...
> > > systemd: PID file /var/run/nginx.pid not readable (yet?) after start.
> > > systemd: Started nginx - high performance web server
>
> > either the daemon needs to be fixed
>
> Ok, but can you tell, what is wrong with daemon?
There is nothing wrong with nginx per se. I am using a nginx.service
file similar to the following one:
https://git.pengutronix.de/cgit/ptxdist/plain/projectroot/usr/lib/systemd/system/nginx.service
If nginx was not built with --pid-path=/var/run/nginx.pid you have to
override it in your nginx.conf with the correct pid path, e.g.
pid /var/run/nginx.pid;
See http://nginx.org/en/docs/ngx_core_module.html#pid
(Your error looks like nginx did create the pid file somewhere else and
systemd can't find it)
Buildroot has a different approach. They add that pid config line, etc.
to the nginx command, so you do not have to add it to your nginx.conf:
https://github.com/buildroot/buildroot/blob/master/package/nginx/nginx.service
Cheers,
Clemens
More information about the systemd-devel
mailing list