mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: support exec on lock
The lock command is clumsy to use from the command line, needing mkfifo, wait, etc. Instead, make like consul and support launching a command if one is given.
This commit is contained in:
@@ -790,7 +790,7 @@ Prints a line of JSON encoding the database hash, revision, total keys, and size
|
||||
|
||||
## Concurrency commands
|
||||
|
||||
### LOCK \<lockname\>
|
||||
### LOCK \<lockname\> [command arg1 arg2 ...]
|
||||
|
||||
LOCK acquires a distributed named mutex with a given name. Once the lock is acquired, it will be held until etcdctl is terminated.
|
||||
|
||||
@@ -798,13 +798,24 @@ LOCK acquires a distributed named mutex with a given name. Once the lock is acqu
|
||||
|
||||
Once the lock is acquired, the result for the GET on the unique lock holder key is displayed.
|
||||
|
||||
If a command is given, it will be launched with environment variables `ETCD_LOCK_KEY` and `ETCD_LOCK_REV` set to the lock's holder key and revision.
|
||||
|
||||
#### Example
|
||||
|
||||
Acquire lock with standard output display:
|
||||
|
||||
```bash
|
||||
./etcdctl lock mylock
|
||||
# mylock/1234534535445
|
||||
```
|
||||
|
||||
Acquire lock and execute `echo lock acquired`:
|
||||
|
||||
```bash
|
||||
./etcdctl lock mylock echo lock acquired
|
||||
# lock acquired
|
||||
```
|
||||
|
||||
#### Remarks
|
||||
|
||||
LOCK returns a zero exit code only if it is terminated by a signal and releases the lock.
|
||||
|
||||
Reference in New Issue
Block a user