1
0
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:
Konstantin Koroviev
2015-03-12 12:05:10 +02:00
parent d23bed5baa
commit 01db359c0f

View File

@ -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()