|
@@ -21,6 +21,7 @@ import (
|
|
|
|
|
|
"git.scraperwall.com/scw/data"
|
|
"git.scraperwall.com/scw/data"
|
|
"git.scraperwall.com/scw/ip"
|
|
"git.scraperwall.com/scw/ip"
|
|
|
|
+ "git.scraperwall.com/scw/pidfile"
|
|
)
|
|
)
|
|
|
|
|
|
var (
|
|
var (
|
|
@@ -34,6 +35,7 @@ var (
|
|
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)")
|
|
useXForwardedAsSource = flag.Bool("use-x-forwarded", false, "Use the IP address in X-Forwarded-For as source")
|
|
useXForwardedAsSource = flag.Bool("use-x-forwarded", false, "Use the IP address in X-Forwarded-For as source")
|
|
|
|
+ pidFile = flag.String("pidfile", "/var/run/munchclient.pid", "The location of the PID file")
|
|
doVersion = flag.Bool("version", false, "Show version information")
|
|
doVersion = flag.Bool("version", false, "Show version information")
|
|
|
|
|
|
natsEC *nats.EncodedConn
|
|
natsEC *nats.EncodedConn
|
|
@@ -55,12 +57,17 @@ func init() {
|
|
}
|
|
}
|
|
|
|
|
|
func main() {
|
|
func main() {
|
|
-
|
|
|
|
if *doVersion {
|
|
if *doVersion {
|
|
version()
|
|
version()
|
|
os.Exit(0)
|
|
os.Exit(0)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if err := pidfile.Write(*pidFile); err != nil {
|
|
|
|
+ log.Fatal("munchclient is already running, exiting!")
|
|
|
|
+ os.Exit(1)
|
|
|
|
+ }
|
|
|
|
+ defer pidfile.Remove(*pidFile)
|
|
|
|
+
|
|
go func(c *uint64) {
|
|
go func(c *uint64) {
|
|
for {
|
|
for {
|
|
fmt.Printf("%d requests per second\n", *c)
|
|
fmt.Printf("%d requests per second\n", *c)
|