Use LockDB in any OS with the CLI.


You can find the binary for your system in the latest release.

Here's an example for Linux intel (x86_64), on downloading it with curl and moving it to /usr/local/bin/ so it's available globally as lockdb:

# Download the binary from the latest release for your system and move it to `/usr/local/bin/`. Here's an example for most Linux OSes:
curl -L --output lockdb && \
chmod +x lockdb && \
sudo mv lockdb /usr/local/bin/


# Set ENV variables
export LOCKDB_SERVICE_ID="reports"
export LOCKDB_API_KEY="api-key"

# Check on a lock
lockdb check sales
# Outputs `false`

# Obtain a lock, waiting up to 30 seconds for it
lockdb lock sales
# Outputs `true` or a TimeoutError

# Unlock a lock, returning if it was locked before
lockdb unlock sales
# Outputs `true`

# Check on multiple locks
lockdb check sales,report,cleanup
# Outputs `false`


Here are all the optional arguments in all commands.

# Locking
lockdb lock sales --service-id="reports" --api-key="api-key" --server-url="" --wait-timeout-in-ms=30000 --unlock-webhook-url="" --lock-expiration-in-s=300

# Locking, short arguments version
lockdb lock sales -i "reports" -a "api-key" -s "" -w 30000 -u "" -l 300

# Unlocking
lockdb unlock sales --service-id="reports" --api-key="api-key" --server-url="" --wait-timeout-in-ms=5000

# Checking
lockdb check sales --service-id="reports" --api-key="api-key" --server-url="" --wait-timeout-in-ms=5000

# Alternatively, you can set environment variables for `--service-id`, `--api-key`, and `--server-url`, and omit those arguments:
export LOCKDB_SERVICE_ID="reports"
export LOCKDB_API_KEY="api-key"