April 07, 2010 09:24AM
Hi there,

I'm looking for a way to find the fully qualified path of the "PID" file at run time. Basically, I've got some code that I need to run when the server is starting, and some different code I need to run when the server is shutting down (daemon mode).

I use fopen("logs/nginx.pid", "r") == NULL to decide if the file exists of not.

If it doesn't, I assume the server is starting. If it does, I assume the server is shutting down. I am aware that this code must execute before the pid file is created to work, which it does. This all works fine, except the location I'm starting it from must be relative to the path I give in fopen. Thus, I have to start it in the same folder as logs, usually by saying sbin/nginx. I want to be able to start it from anywhere, thus I want to use the fully qualified path of the pid file instead of it's relative path. I suppose even if I knew the full executable path, I could escape it one level up and tack on logs/nginx.pid but knowing the pid itself would likely be better.

So does nginx make the location of the pid file available at run time? Is there a way I can extract the full location of the PID (or exe) at run time? Thanks!
Subject Author Posted

Location of PID file (or executable) at runtime

Tronman April 07, 2010 09:24AM

Re: Location of PID file (or executable) at runtime

Tronman April 07, 2010 09:33AM

Re: Location of PID file (or executable) at runtime

Reinis Rozitis April 07, 2010 05:38PM

Re: Location of PID file (or executable) at runtime

Manlio Perillo April 07, 2010 05:46PM

Re: Location of PID file (or executable) at runtime

Tronman April 07, 2010 05:51PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready