Project

pidfile

0.03
No commit activity in last 3 years
No release in over 3 years
false
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

PidFile¶ ↑

github.com/samullen/pidfile

A basic library for creating lockfiles for processes

This library works with Ruby 1.8 and 1.9 and is licensed under the MIT License.

Installation¶ ↑

The pidfile gem is hosted on RubyGems.org (rubygems.org). This requires that you have rubygems.org in your gem sources.

Install the pidfile gem:

sudo gem install pidfile

Gettings Started¶ ↑

The pidfile gem is easy to use and only requires the instantiation of the pidfile, like so:

pf = PidFile.new

Of course there is other functionality, but if you are just wanting to keep a process from running more than once, this is all you need.

Arguments¶ ↑

PidFile creates file to store the process ID (PID). By default, process ID (PID) files are created in /tmp upon instantiation and are given the same name as the calling script with a .pid extension. Process ID files are removed when the creating program exits.

Each argument, :pidfile and :piddir, can be changed upon instantiation of the class.

Example:¶ ↑

PidFile.new(:piddir => '/var/lock', :pidfile => "awesome.pid")

Miscellaneous¶ ↑

Why isn’t this a singleton?¶ ↑

My main concern is how it would behave when a process is forked multiple times. Each new process would get its own PID, but I wasn’t sure how using a singleton would affect this; if the interrelationship of the processes would keep the object from correctly identifying the correct pidfile.

Anyway, I like the flexibility that not using a singleton offers, and I guess I’d rather ask you not to do something bad rather than restraining you.

Copyright© 2010 Samuel Mullen (samullen). See LICENSE for details