Grab Daemon
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A Hierarchical Perishable Lock Service

Perishable locks are locks with a relatively short time to live (usually about a minute or so), and which are expected to be refreshed via some keep-alive or polling process until they are no longer required.

The intended use is for continuous builds via jenkins or similar services.

Builds are notoriously fickle, and crash or are terminated by impatient users. Builds also make use of shared resources, and sometimes require exclusive access. Using traditional locking mechanisms requires cleanup to avoid stale locks.

This service works around the problem of stale locks by incorporating the cleanup mechanism and releasing locks that haven't been refreshed within a given timespan.

Features include:

  • Hierarchical locking structure via resource paths. The last item in the path gets an exclusive lock, and the items in the path get shared locks.
  • Queues for every resource ensure "first come first serve", as opposed to "whoever shows up at the right time gets it".
  • REST api using simple GET requests returning JSON responses.
  • Pure in memory state, no databases or files required.
  • Clean shutdown to preserve continuous service even during upgrades.
  • Support for long term locking (e.g. code freeze / maintenance) by setting lock expiration time into the future.
  • Client "keepalive" process monitors parent process and is able to run a cleanup script should the parent process die or be killed.


grab.js Node script containing the actual server code. Run "node grab.js --help" to see the configuration options. Python client script. Run "python --help" to see the options. Wrapper script to cleanly restart the service. Unit test runner. Sample grab() and release() shell functions using the locking service with keep-alive process.

Sample Usage

First ensure you have python and node installed, then:

  1. start the service by running ./
  2. optionally, in a separate window, tail -f ./log
  3. run the sample script: ./
  4. try more experiments by using
  5. stop the service: ./ shutdown
  6. inspect the log file:

See Also