Process ID file management for background services
The pid files contains the process id (a number) of a given program. For example, Apache HTTPD may write it's main process number to a pid file - which is a regular text file, nothing more than that - and later use the information there contained to stop itself. You can also use that information (just do a cat filename.pid) to kill the process yourself, using echo filename.pid | xargs kill.
Path is a helper function that computes the best possible PID file for the
current system, by first attempting to get the user directory then
resorting to /var/run on Linux systems and elsewhere on other systems.
type PID struct {
PID int `json:"pid"` // The process id assigned by the OS PPID int `json:"ppid"` // The parent process id// contains filtered or unexported fields
}
PID describes the server process and is accessed by both the server and the
command line client in order to facilitate cross-process communication.
New PID file at the given location. Note that this function only creates
an empty PID, which can then be loaded or saved in order to obtain
process information.
Free the PID file (delete it) -- used by the server on shutdown to cleanup
and ensure that stray process information isn't just lying about.
Does not return an error if the PID file does not exist.