panics and retry 0
parent
aaeac9b852
commit
59c834c5c6
|
@ -120,9 +120,9 @@ func main() {
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
fmt.Printf("-v [TRUE] for verbose output on stdout")
|
fmt.Printf("-v [TRUE] for verbose output on stdout")
|
||||||
fmt.Printf("-ce [TRUE] if destination is set to ip:port, use of tls")
|
fmt.Printf("-ce [TRUE] if destination is set to ip:port, use of tls")
|
||||||
fmt.Printf("-ct [300] if destination is set to ip:port, timeout in seconds")
|
fmt.Printf("-ct [300] if destination is set to ip:port, timeout")
|
||||||
fmt.Printf("-cka [3600] if destination is set to ip:port, keepalive in seconds")
|
fmt.Printf("-cka [3600] if destination is set to ip:port, keepalive")
|
||||||
fmt.Printf("-retry [5] if destination is set to ip:port, keepalive in seconds")
|
fmt.Printf("-retry [5] if destination is set to ip:port, retry period ")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,17 +143,18 @@ func main() {
|
||||||
defer fmt.Print(&buf)
|
defer fmt.Print(&buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add flags for timeouts / fail on disconnect
|
|
||||||
c := make(chan string)
|
c := make(chan string)
|
||||||
for {
|
for {
|
||||||
if set(d4p) {
|
if set(d4p) {
|
||||||
go d4Copy(d4p, c)
|
go d4Copy(d4p, c)
|
||||||
} else {
|
} else if d4.retry > 0 {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(d4.retry)
|
time.Sleep(d4.retry)
|
||||||
infof(fmt.Sprintf("Sleeping for %f seconds before retry.\n", d4.retry.Seconds()))
|
infof(fmt.Sprintf("Sleeping for %f seconds before retry.\n", d4.retry.Seconds()))
|
||||||
c <- "done waiting"
|
c <- "done waiting"
|
||||||
}()
|
}()
|
||||||
|
} else {
|
||||||
|
panic("Unrecoverable error without retry.")
|
||||||
}
|
}
|
||||||
<-c
|
<-c
|
||||||
}
|
}
|
||||||
|
@ -274,6 +275,8 @@ func setReaderWriters(d4 *d4S) bool {
|
||||||
case "file":
|
case "file":
|
||||||
f, _ := os.Create("test.txt")
|
f, _ := os.Create("test.txt")
|
||||||
(*d4).dst = newD4Writer(f, (*d4).conf.key)
|
(*d4).dst = newD4Writer(f, (*d4).conf.key)
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("No suitable destination found, given :%q", (*d4).conf.destination))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue