Ever wanted to coordinate shell scripts? Use lockutil to acquire a lock or fail:
Script 1:
lock
trap "lock release" INT EXIT
sleep 1000
Script 2:
lock -timeout 10
trap "lock release" INT EXIT
echo "a"
Will print 'a' only after script 1 has finished.
acquire lock
release lock
list all active locks
force a lock release, a secret token must be provided
Wait for this number of seconds to acquire lock. If it takes longer, it fails.
The port to connect to, defaulting to 50051
The host to connect to, defaulting to localhost
The name of the lock to acquire, defaulting to 'default'
Prints help a message
Enables verbose logging
The port to listen on, defaulting to 50051
The host address to listen on, defaulting to localhost
The name of the lock to acquire, defaulting to 'default'
Prints a help message
pass to enable forcefully unlocks
In lockutil.go a client library is provided for use in go applications.