summaryrefslogtreecommitdiff
path: root/cmd/cli/workers.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-24 10:39:05 +0300
committerValery Piashchynski <[email protected]>2020-12-24 10:39:05 +0300
commit62ee1770cc233328300438ffd690ea1d8fc747bb (patch)
treeadc7d78e28a9512cb1b1ba85cb4f19dec7d1323d /cmd/cli/workers.go
parente78c13d93a729a9008f283aa3db6910f3e833165 (diff)
Remove local replace in the go.mod
Diffstat (limited to 'cmd/cli/workers.go')
-rw-r--r--cmd/cli/workers.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/cmd/cli/workers.go b/cmd/cli/workers.go
index 4bcbbdbd..d34de40a 100644
--- a/cmd/cli/workers.go
+++ b/cmd/cli/workers.go
@@ -5,6 +5,8 @@ import (
"log"
"net/rpc"
"os"
+ "os/signal"
+ "syscall"
"time"
tm "github.com/buger/goterm"
@@ -68,11 +70,18 @@ func workersHandler(cmd *cobra.Command, args []string) error {
return showWorkers(plugins, client)
}
+ // https://golang.org/pkg/os/signal/#Notify
+ // should be of buffer size at least 1
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
+
tm.Clear()
tt := time.NewTicker(time.Second)
defer tt.Stop()
for {
select {
+ case <-c:
+ return nil
case <-tt.C:
tm.MoveCursor(1, 1)
err := showWorkers(plugins, client)