This is a ruby library for using pid-file based locking of programs/daemons to prevent multiple parallel running tasks.
The gem sys/proctable
is required.
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
- test unlocking in projects.
- Greg Whiteley (https:/github/com/whitty)