Receiving a SIGUSR2 makes Vault log the running goroutines' stacks. (#6240)

* Receiving a SIGUSR2 makes Vault log the running goroutines' stacks.
This commit is contained in:
ncabatoff
2019-03-15 09:27:53 -04:00
committed by GitHub
parent 61299b0502
commit ccfeef6688
3 changed files with 25 additions and 0 deletions

View File

@@ -466,6 +466,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
PhysicalBackends: physicalBackends,
ShutdownCh: MakeShutdownCh(),
SighupCh: MakeSighupCh(),
SigUSR2Ch: MakeSigUSR2Ch(),
}, nil
},
"ssh": func() (cli.Command, error) {
@@ -628,3 +629,20 @@ func MakeSighupCh() chan struct{} {
}()
return resultCh
}
// MakeSigUSR2Ch returns a channel that can be used for SIGUSR2
// goroutine logging. This channel will send a message for every
// SIGUSR2 received.
func MakeSigUSR2Ch() chan struct{} {
resultCh := make(chan struct{})
signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, syscall.SIGUSR2)
go func() {
for {
<-signalCh
resultCh <- struct{}{}
}
}()
return resultCh
}