About
zklock.py allows you to run any shell command while acquiring distributed lock over Zookeeper, similar what flock does except it acquires local lock (over local file).
Requirements
This script requires kazoo python module, you can find out more about it here
Usage
Command line only
zklock.py --server zookeeper.example.com --port 2181 --project test --command "service test restart"
Command line with configuration file
zklock.conf
[zklock]
server = zookeeper.example.com
port = 2181
lock_timeout = 10
delay_exec = 1
project = test
command = service test restart
zklock.py --config zklock.conf
Also if you want or need to, you can simulate different states by using true/false commands
Simulate OK state
zklock.py --server zookeeper.example.com --port 2181 --project test --command true
Simulate FAILED state
zklock.py --server zookeeper.example.com --port 2181 --project test --command false
License and Authors
Author: Milos Buncic
On this page
Contributors
GNU General Public License v3.0
Created December 28, 2016
Updated February 22, 2019