Checking config outputs a pid file

Hi all,

Has anyone noticed that `nginx -t’ outputs an empty pid file while the
nginx process isn’t running.

I can only add
if [ ! -s $PID ]; then
rm -f $PID
fi
to the check-config section of my rc file at the moment.

On Tue, May 27, 2008 at 11:53 AM, Cherife Li [email protected]
wrote:

Hi all,

Has anyone noticed that `nginx -t’ outputs an empty pid file while the
nginx process isn’t running.

no, but good catch!!!

I can only add
if [ ! -s $PID ]; then
rm -f $PID
fi
to the check-config section of my rc file at the moment.

you dont need to, as far as i can tell. nginx just proceeds to overwrite
that file with the proper value when it starts up…

-jf


In the meantime, here is your PSA:
“It’s so hard to write a graphics driver that open-sourcing it would not
help.”
– Andrew Fear, Software Product Manager, NVIDIA Corporation

On Tue, May 27, 2008 at 11:53:45AM +0800, Cherife Li wrote:

Hi all,

Has anyone noticed that `nginx -t’ outputs an empty pid file while the
nginx process isn’t running.

I can only add
if [ ! -s $PID ]; then
rm -f $PID
fi
to the check-config section of my rc file at the moment.

Yes, nginx creates pid file on -t to test possibility to create it.
It does not write any pid there and does not remove it.
The later was done intentionally because there may be race condition
when nginx startes, creates file, then someone run nginx -t, it creates
file, and deletes it.

On Tue, May 27, 2008 at 1:31 PM, Igor S. [email protected] wrote:

fi
to the check-config section of my rc file at the moment.

Yes, nginx creates pid file on -t to test possibility to create it.
It does not write any pid there and does not remove it.
The later was done intentionally because there may be race condition
when nginx startes, creates file, then someone run nginx -t, it creates
file, and deletes it.

so in this case, if the file is there already, then running nginx -t
will
assume that the file creation is ok, and not do anything to it? This
seems
to be the case for my tests.

-jf


In the meantime, here is your PSA:
“It’s so hard to write a graphics driver that open-sourcing it would not
help.”
– Andrew Fear, Software Product Manager, NVIDIA Corporation

On 05/27/08 12:52, Jeffrey ‘jf’ Lim wrote:

No?
I’m using 0.7.1.

that file with the proper value when it starts up…

Yeah, ur right.

And I got some more info from debug.
With v0.7.1 running, when do another start, nginx will try to bind the
addr for 5 times while the addr is in use, if the addr is still
unavailable after 2.5s, then gives up. But the start command won’t give
any info, just quietly exit. So I thought nginx has started regularly,
but in fact not that case.

So I always do process checking(check pid file) and warning in rc files,
including nginx’.

The problem is nginx does give me an empty pid file.

On 05/27/08 13:48, Jeffrey ‘jf’ Lim wrote:

 >
file, and deletes it.

so in this case, if the file is there already, then running nginx -t
will assume that the file creation is ok, and not do anything to it?
This seems to be the case for my tests.

Emm, same here.
Besides, it test binding the addr.

On 05/27/08 13:31, Igor S. wrote:

fi
to the check-config section of my rc file at the moment.

Yes, nginx creates pid file on -t to test possibility to create it.
It does not write any pid there and does not remove it.
The later was done intentionally because there may be race condition
when nginx startes, creates file, then someone run nginx -t, it creates
file, and deletes it.

Just saw ur reply, Igor. Got it.
Thanks all.

On Tue, May 27, 2008 at 01:48:11PM +0800, Jeffrey ‘jf’ Lim wrote:

if [ ! -s $PID ]; then
so in this case, if the file is there already, then running nginx -t will
assume that the file creation is ok, and not do anything to it? This seems
to be the case for my tests.

No, nginx always tries to create pid file, with -t and without it.
If the file already exists, it is leaved as is.