func init() { dvid.SetLogMode(dvid.WarningMode) }
func main() { flag.BoolVar(showHelp, "h", false, "Show help message") flag.Usage = usage flag.Parse() if flag.NArg() == 0 { flag.Usage() os.Exit(0) } help := strings.ToLower(flag.Args()[0]) == "help" if help && flag.NArg() == 1 { *showHelp = true } if *showHelp || flag.NArg() == 0 { flag.Usage() os.Exit(0) } if help && flag.NArg() == 2 && strings.ToLower(flag.Args()[0]) == "server" { if err := DoCommand(dvid.Command([]string{"help"})); err != nil { fmt.Printf("Unable to get 'help' from DVID server at %q.\n%v\n", rpcAddress, err) } os.Exit(0) } if *runVerbose { dvid.SetLogMode(dvid.DebugMode) } if *readonly { server.SetReadOnly(true) } if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { log.Fatal(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } // Determine numer of logical CPUs on local machine and unless overridden, use // all of them. numCPU := runtime.NumCPU() if *useCPU != 0 { dvid.NumCPU = *useCPU } else if flag.NArg() >= 1 && flag.Args()[0] == "serve" { dvid.NumCPU = numCPU } else { dvid.NumCPU = 1 } runtime.GOMAXPROCS(dvid.NumCPU) command := dvid.Command(flag.Args()) if err := DoCommand(command); err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } }