mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 14:24:39 +00:00
Merge pull request #3120 from hashicorp/better-shutdown-logs
agent: log different shutdown stages
This commit is contained in:
commit
24ebe5cc30
@ -800,6 +800,7 @@ func (cmd *Command) Run(args []string) int {
|
|||||||
|
|
||||||
graceful := (sig == os.Interrupt && !(*config.SkipLeaveOnInt)) || (sig == syscall.SIGTERM && (*config.LeaveOnTerm))
|
graceful := (sig == os.Interrupt && !(*config.SkipLeaveOnInt)) || (sig == syscall.SIGTERM && (*config.LeaveOnTerm))
|
||||||
if !graceful {
|
if !graceful {
|
||||||
|
cmd.UI.Output("Graceful shutdown disabled. Exiting")
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,7 +808,7 @@ func (cmd *Command) Run(args []string) int {
|
|||||||
gracefulCh := make(chan struct{})
|
gracefulCh := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
if err := agent.Leave(); err != nil {
|
if err := agent.Leave(); err != nil {
|
||||||
cmd.UI.Error(fmt.Sprintf("Error: %s", err))
|
cmd.UI.Error(fmt.Sprintf("Error on leave: %s", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
close(gracefulCh)
|
close(gracefulCh)
|
||||||
@ -816,10 +817,13 @@ func (cmd *Command) Run(args []string) int {
|
|||||||
gracefulTimeout := 5 * time.Second
|
gracefulTimeout := 5 * time.Second
|
||||||
select {
|
select {
|
||||||
case <-signalCh:
|
case <-signalCh:
|
||||||
|
cmd.UI.Output(fmt.Sprintf("Caught second signal: %v. Exiting", sig))
|
||||||
return 1
|
return 1
|
||||||
case <-time.After(gracefulTimeout):
|
case <-time.After(gracefulTimeout):
|
||||||
|
cmd.UI.Output("Timeout on graceful leave. Exiting")
|
||||||
return 1
|
return 1
|
||||||
case <-gracefulCh:
|
case <-gracefulCh:
|
||||||
|
cmd.UI.Output("Graceful exit completed")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user