// options package main import ( // "encoding/json" "flag" "fmt" // "io/ioutil" "log" "os" "path" "path/filepath" "time" ) type Options struct { RedisTTL time.Duration CurrentPath string Exe string LogFile string ConfigFile string Timeout time.Duration Debug bool Version bool Concurrent int MaxError int Xymon string Hostname string } func usage() { fmt.Println("Usage: llmongo -m -r -t -l -b -T -x -H -v\n") os.Exit(0) } func init() { var err error opts.CurrentPath, err = filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { log.Fatal(err) } opts.LogFile = path.Join(opts.CurrentPath, opts.LogFile) pid.PIDFile = path.Join(opts.CurrentPath, "run", path.Base(os.Args[0])+".pid") opts.Exe = path.Base(os.Args[0]) flag.StringVar(&opts.Xymon, "x", "", "xymon server") flag.StringVar(&opts.Hostname, "H", "", "hostname") flag.StringVar(&dbs.MongoUri, "m", dbs.MongoUri, "Mongodb") flag.StringVar(&dbs.RedisUri, "r", dbs.RedisUri, "Redis") flag.StringVar(&opts.LogFile, "l", opts.LogFile, "Logs filename") flag.DurationVar(&opts.RedisTTL, "t", opts.RedisTTL, "Redis keys TTL") flag.BoolVar(&opts.Version, "v", false, "Version") flag.DurationVar(&opts.Timeout, "T", 0, "Running timeout") flag.BoolVar(&opts.Debug, "D", false, "Debug") flag.IntVar(&opts.Concurrent, "c", 1, "Concurrent thread") flag.IntVar(&opts.MaxError, "E", 100, "Max Mongodb Error") }