mirror of
https://github.com/status-im/consul.git
synced 2025-02-02 17:03:31 +00:00
command/lock: Check for shutdown during lock acquisition. Fixes #800
This commit is contained in:
parent
cfa7ed71a7
commit
981c62ccba
@ -71,6 +71,7 @@ Options:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *LockCommand) Run(args []string) int {
|
func (c *LockCommand) Run(args []string) int {
|
||||||
|
var childDone chan struct{}
|
||||||
var name, token string
|
var name, token string
|
||||||
var limit int
|
var limit int
|
||||||
cmdFlags := flag.NewFlagSet("watch", flag.ContinueOnError)
|
cmdFlags := flag.NewFlagSet("watch", flag.ContinueOnError)
|
||||||
@ -147,8 +148,16 @@ func (c *LockCommand) Run(args []string) int {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we were shutdown but managed to still acquire the lock
|
||||||
|
select {
|
||||||
|
case <-c.ShutdownCh:
|
||||||
|
c.Ui.Error("Shutdown triggered during lock acquisition")
|
||||||
|
goto RELEASE
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
// Start the child process
|
// Start the child process
|
||||||
childDone := make(chan struct{})
|
childDone = make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
if err := c.startChild(script, childDone); err != nil {
|
if err := c.startChild(script, childDone); err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("%s", err))
|
c.Ui.Error(fmt.Sprintf("%s", err))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user