|
@@ -40,6 +40,7 @@ var (
|
|
natsPassword = flag.String("nats-password", "", "The password for NATS authentication")
|
|
natsPassword = flag.String("nats-password", "", "The password for NATS authentication")
|
|
natsQueue = flag.String("nats-queue", "requests", "The NATS queue name")
|
|
natsQueue = flag.String("nats-queue", "requests", "The NATS queue name")
|
|
natsCA = flag.String("nats-ca", "", "CA chain for NATS TLS")
|
|
natsCA = flag.String("nats-ca", "", "CA chain for NATS TLS")
|
|
|
|
+ reconnectToNatsAfter = flag.Duration("reconnect-to-nats-after", 0, "reconnect to nats after this long periodically")
|
|
sleepFor = flag.Duration("sleep", 0, "Sleep this long between sending data (only when replaying a file)")
|
|
sleepFor = flag.Duration("sleep", 0, "Sleep this long between sending data (only when replaying a file)")
|
|
requestsFile = flag.String("requests", "", "CSV file containing requests (IP and URL)")
|
|
requestsFile = flag.String("requests", "", "CSV file containing requests (IP and URL)")
|
|
protocol = flag.String("protocol", "http", "which protocol to parse: http or ajp13")
|
|
protocol = flag.String("protocol", "http", "which protocol to parse: http or ajp13")
|
|
@@ -179,6 +180,17 @@ func main() {
|
|
log.Fatal(err)
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // reconnect to nats periodically
|
|
|
|
+ //
|
|
|
|
+ if *reconnectToNatsAfter > 0 {
|
|
|
|
+ go func(interval time.Duration) {
|
|
|
|
+ for range time.Tick(interval) {
|
|
|
|
+ natsEC.Conn.Close()
|
|
|
|
+ natsJSONEC.Conn.Close()
|
|
|
|
+ }
|
|
|
|
+ }(*reconnectToNatsAfter)
|
|
|
|
+ }
|
|
|
|
+
|
|
go natsWatchdog(natsErrorChan)
|
|
go natsWatchdog(natsErrorChan)
|
|
|
|
|
|
// RPC
|
|
// RPC
|