mkraft/with_locking — pull request #1 by francois (2014-07-12 04:29:27+00:00)
Title: Enable specifying the location of the `piddir`

The PIDDIR should be stable between deploys, and should not live in a local directory of the module that's being deployed. This gives us a few different ways to configure it:

Locally, on each call:

WithLocking.run(name: "a", piddir: "/var/run") { ... }
# locks /var/run/a.pid

Globally, in-process:

WithLocking.piddir = "/var/local/run"
WithLocking.run(name: "a") { }
# locks /var/local/run/a.pid

Globally, outside the process:

ENV["WITH_LOCKING_PIDDIR"] = "/var/run/myapp"
WithLocking.run(name: "a") { }
# locks: /var/run/myapp/a.pid