cmd: add siginfo handler

s3-about
kubatasiemski 2018-05-13 20:24:56 +02:00 committed by Nick Craig-Wood
parent 2a29f7f6c8
commit de8c7d8e45
3 changed files with 31 additions and 0 deletions

View File

@ -303,6 +303,7 @@ func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
if showStats {
stopStats = StartStats()
}
SigInfoHandler()
for try := 1; try <= *retries; try++ {
err = f()
if !Retry || (err == nil && !accounting.Stats.Errored()) {

23
cmd/siginfo_darwin.go Normal file
View File

@ -0,0 +1,23 @@
//+build darwin
package cmd
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/ncw/rclone/fs/accounting"
)
// SigInfoHandler creates SigInfo handler
func SigInfoHandler() {
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINFO)
go func() {
for range signals {
log.Printf("%v\n", accounting.Stats)
}
}()
}

7
cmd/siginfo_others.go Normal file
View File

@ -0,0 +1,7 @@
//+build !darwin
package cmd
// SigInfoHandler creates SigInfo handler
func SigInfoHandler() {
}