package
Simple OS-wide generic locking for node.js on Linux using abstract sockets
npm install padlockerGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
13.4 kB
Includes dependencies.
Simple OS-wide generic locking for node.js on Linux using abstract sockets. The use of abstract sockets allows for automatic unlocking when the process exits.
Linux
npm install padlockerconst PadLocker = require('padlocker');
const locker = new PadLocker('foo.bar.baz.lock');
(async() => {
await locker.lock();
// Do something
await locker.unlock();
})();
require('padlocker') returns the PadLocker constructor.
(constructor)(< string >name) - Creates and returns a new PadLocker instance.
lock([< integer >retries[, < integer >retryDelay]]) - Promise - Attempts to acquire the lock. retries if defined, must be a positive integer or Infinity that represents how many attempts to make after the first try if unsuccessful (Default: Infinity). retryDelay if defined, must be a positive integer representing how many milliseconds to wait between retries (Default: 250ms).
unlock() - Promise - Releases the lock.