Command-line tool to create and delete distributed locks using Cassandra and lightweight transactions. These tools are useful for managing distributed jobs on multiple hosts.
Set up a config file at `~/.cqllockrc` or `/etc/cqllock.yaml` in the following YAML format:
timeout: 10 # This is the Cassandra connectiont timeout in seconds
retries: 3 # This is the number of times to retry failed Cassandra queries
### Possible scenarios
##### Ensure a process only runs once ever, regardless of how many times or on what host it's attempted:
cqllock ProcessLock && ./myProcess.sh
The first call to cqllock that successfully acquires the lock will hold it forever. Further calls to cqllock will return non-zero, so ./myProcess.sh won't run again.
This command can be run on multiple hosts.
##### Multiple hosts run a job, but only allow one at a time:
cqllock -t 1d -r 5m jobLock && ./myJob.sh ; cqllock -u jobLock
The first host to acquire the lock will hold it until ./myJob.sh finishes. Other hosts will attempt to acquire the lock every five minutes and will wait up to one day
trying to reaquire the lock.
There are likely other useful scenarios.