cmd: add siginfo handler
This commit is contained in:
parent
2a29f7f6c8
commit
de8c7d8e45
3 changed files with 31 additions and 0 deletions
|
@ -303,6 +303,7 @@ func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
|
||||||
if showStats {
|
if showStats {
|
||||||
stopStats = StartStats()
|
stopStats = StartStats()
|
||||||
}
|
}
|
||||||
|
SigInfoHandler()
|
||||||
for try := 1; try <= *retries; try++ {
|
for try := 1; try <= *retries; try++ {
|
||||||
err = f()
|
err = f()
|
||||||
if !Retry || (err == nil && !accounting.Stats.Errored()) {
|
if !Retry || (err == nil && !accounting.Stats.Errored()) {
|
||||||
|
|
23
cmd/siginfo_darwin.go
Normal file
23
cmd/siginfo_darwin.go
Normal 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
7
cmd/siginfo_others.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
//+build !darwin
|
||||||
|
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
// SigInfoHandler creates SigInfo handler
|
||||||
|
func SigInfoHandler() {
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue