mirror of
https://github.com/rclone/rclone
synced 2024-11-25 02:47:14 +01:00
cmd: add siginfo handler
This commit is contained in:
parent
2a29f7f6c8
commit
de8c7d8e45
@ -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
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…
Reference in New Issue
Block a user