mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 04:37:30 +08:00
Kill the daemon during its startup
This commit is contained in:
@ -481,15 +481,20 @@ func (i *cmdInvocation) setupInterruptHandler() {
|
|||||||
sig := allInterruptSignals()
|
sig := allInterruptSignals()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// wait till the context is ready to be closed
|
|
||||||
<-ctx.InitDone
|
|
||||||
|
|
||||||
// first time, try to shut down.
|
// first time, try to shut down.
|
||||||
|
|
||||||
// loop because we may be
|
// loop because we may be
|
||||||
for count := 0; ; count++ {
|
for count := 0; ; count++ {
|
||||||
<-sig
|
<-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
|
// TODO cancel the command context instead
|
||||||
|
|
||||||
n, err := ctx.GetNode()
|
n, err := ctx.GetNode()
|
||||||
|
Reference in New Issue
Block a user