Merge pull request #10117 from jingyih/improve_doc_on_etcdctl_lock

etcdctl: improve doc on etcdctl lock command
This commit is contained in:
Xiang Li 2018-09-24 15:22:13 -07:00 committed by GitHub
commit 2cf4736621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1056,7 +1056,7 @@ echo ${transferee_id}
### LOCK [options] \<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.
LOCK acquires a distributed mutex with a given name. Once the lock is acquired, it will be held until etcdctl is terminated.
#### Options
@ -1064,9 +1064,9 @@ LOCK acquires a distributed named mutex with a given name. Once the lock is acqu
#### Output
Once the lock is acquired, the result for the GET on the unique lock holder key is displayed.
Once the lock is acquired but no command is given, 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.
If a command is given, it will be executed with environment variables `ETCD_LOCK_KEY` and `ETCD_LOCK_REV` set to the lock's holder key and revision.
#### Example
@ -1084,6 +1084,12 @@ Acquire lock and execute `echo lock acquired`:
# lock acquired
```
Acquire lock and execute `etcdctl put` command
```bash
./etcdctl lock mylock ./etcdctl put foo bar
# OK
```
#### Remarks
LOCK returns a zero exit code only if it is terminated by a signal and releases the lock.