diff --git a/main.go b/main.go index 98671c6..96c41c4 100644 --- a/main.go +++ b/main.go @@ -15,11 +15,6 @@ const ( ) var ( - opts = Options{ - RedisTTL: time.Hour * 11688, // 16 mesi - LogFile: "log/llmongo.log", - } - loop []bool done []chan bool @@ -59,7 +54,7 @@ func main() { log.SetOutput(fs) - // DA VERIFICARE + pid.PIDFile = opts.Pidfile pid.Write(true) defer pid.Remove() diff --git a/options.go b/options.go index 18f483e..2fab11c 100644 --- a/options.go +++ b/options.go @@ -28,8 +28,16 @@ type Options struct { Influxdb string Hostname string Month string + Pidfile string } +var ( + opts = Options{ + RedisTTL: time.Hour * 11688, // 16 mesi + LogFile: "log/llmongo.log", + } +) + func usage() { fmt.Println("Usage: llmongo -m -r -t -l -b -T -x -H -i -v\n") os.Exit(0) @@ -59,4 +67,5 @@ func init() { flag.BoolVar(&opts.Debug, "D", false, "Debug") flag.IntVar(&opts.Concurrent, "c", 1, "Concurrent thread") flag.IntVar(&opts.MaxError, "E", 100, "Max Mongodb Error") + flag.StringVar(&opts.Pidfile, "p", opts.Pidfile, "pid file") }