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