use ctx.Done() to exit
This commit is contained in:
parent
4f977d21ef
commit
0af9692072
@ -2,9 +2,6 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
cid "github.com/ipfs/go-cid"
|
||||
@ -67,9 +64,6 @@ var syncWaitCmd = &cli.Command{
|
||||
defer closer()
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
sigChan := make(chan os.Signal, 2)
|
||||
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT)
|
||||
|
||||
for {
|
||||
ss, err := napi.SyncState(ctx)
|
||||
if err != nil {
|
||||
@ -88,7 +82,7 @@ var syncWaitCmd = &cli.Command{
|
||||
}
|
||||
|
||||
select {
|
||||
case <-sigChan:
|
||||
case <-ctx.Done():
|
||||
fmt.Println("\nExit by user")
|
||||
return nil
|
||||
case <-time.After(1 * time.Second):
|
||||
|
Loading…
Reference in New Issue
Block a user