Pidlock
This is a ruby library for using pid-file based locking of programs/daemons to prevent multiple parallel running tasks.
Prerequisites
The gem sys/proctable
is required.
Usage
require 'sys/proctable'
pidlock = Pidlock.new('my.pid') # Instantiates a lock
pidlock.lock # tries to create a lock file '/var/run/my.pid';
# raises an error if the file is locked or a program exists that
# has the same basename and pid (here: 'my')
...
pidlock.unlock # closes and removes the file
TODO
- test unlocking in projects.
LICENSE
CONTRIBUTORS
- Greg Whiteley (https:/github/com/whitty)