Class: Daemons::PidFile

Class | Daemons::PidFile
In: | lib/daemons/pidfile.rb
Parent: | Pid

### What is a Pid-File?

A Pid-File is a file containing the process identification number (pid) that is stored in a well-defined location of the filesystem thus allowing other programs to find out the pid of a running script.

Daemons needs the pid of the scripts that are currently running in the background to send them so called signals. Daemons uses the `TERM` signal to tell the script to exit when you issue a `stop` command.

### How does a Pid-File look like?

Pid-Files generated by Daemons have to following format:

      <scriptname>.rb<number>.pid

(Note that `<number>` is omitted if only one instance of the script can run at any time)

Each file just contains one line with the pid as string (for example `6432`).

### Where are Pid-Files stored?

Daemons is configurable to store the Pid-Files relative to three different locations:

1. in a directory relative to the directory where the script (the one that is supposed to run as a daemon) resides (`:script` option for `:dir_mode`)
2. in a directory given by `:dir` (`:normal` option for `:dir_mode`)
3. in the preconfigured directory `/var/run` (`:system` option for `:dir_mode`)

### Methods

cleanup existing exists? filename find_files new pid pid=

### Attributes

dir | [R] |
multiple | [R] |
number | [R] |
progname | [R] |

### Public Class methods

existing(path)
find_files(dir, progname)
new(dir, progname, multiple = false)

### Public Instance methods

cleanup()
exists?()
filename()
pid()
pid=(p)

[Validate]