mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 03:28:25 +08:00
Kill the daemon during its startup
This commit is contained in:
@ -481,15 +481,20 @@ func (i *cmdInvocation) setupInterruptHandler() {
|
||||
sig := allInterruptSignals()
|
||||
|
||||
go func() {
|
||||
// wait till the context is ready to be closed
|
||||
<-ctx.InitDone
|
||||
|
||||
// first time, try to shut down.
|
||||
|
||||
// loop because we may be
|
||||
for count := 0; ; count++ {
|
||||
<-sig
|
||||
|
||||
// if we're still initializing, cannot use `ctx.GetNode()`
|
||||
select {
|
||||
default: // initialization not done
|
||||
fmt.Println("Received interrupt signal, shutting down...")
|
||||
os.Exit(-1)
|
||||
case <-ctx.InitDone:
|
||||
}
|
||||
|
||||
// TODO cancel the command context instead
|
||||
|
||||
n, err := ctx.GetNode()
|
||||
|
Reference in New Issue
Block a user