func main() { home := os.Getenv("HOME") cachedir := flag.String("cachedir", filepath.Join(home, ".cache", "termite-master"), "content cache") workers := flag.String("workers", "", "comma separated list of worker addresses") coordinator := flag.String("coordinator", "localhost:1233", "address of coordinator. Overrides -workers") socket := flag.String("socket", ".termite-socket", "socket to listen for commands") exclude := flag.String("exclude", "/sys,/proc,/dev,/selinux,/cgroup", "prefixes to not export.") secretFile := flag.String("secret", "secret.txt", "file containing password.") srcRoot := flag.String("sourcedir", "", "root of corresponding source directory") jobs := flag.Int("jobs", 1, "number of jobs to run") port := flag.Int("port", 1237, "http status port") flag.Parse() secret, err := ioutil.ReadFile(*secretFile) if err != nil { log.Fatal("ReadFile", err) } workerList := strings.Split(*workers, ",") excludeList := strings.Split(*exclude, ",") c := termite.NewContentCache(*cachedir) master := termite.NewMaster( c, *coordinator, workerList, secret, excludeList, *jobs) master.SetSrcRoot(*srcRoot) go master.ServeHTTP(*port) master.Start(*socket) }
func main() { home := os.Getenv("HOME") cachedir := flag.String("cachedir", filepath.Join(home, ".cache", "termite-master"), "content cache") coordinator := flag.String("coordinator", "localhost:1230", "address of coordinator. Overrides -workers") exclude := flag.String("exclude", "usr/lib/locale/locale-archive,sys,proc,dev,selinux,cgroup", "prefixes to not export.") fetchAll := flag.Bool("fetch-all", true, "Fetch all files on startup.") houseHoldPeriod := flag.Float64("time.household", 60.0, "how often to do house hold tasks.") jobs := flag.Int("jobs", 1, "number of jobs to run") keepAlive := flag.Float64("time.keepalive", 60.0, "for how long to keep workers reserved.") logfile := flag.String("logfile", "", "where to send log output.") memcache := flag.Int("filecache", 256, "number of <128k files to cache in memory") paranoia := flag.Bool("paranoia", false, "Check attribute cache.") port := flag.Int("port", 1231, "http status port") retry := flag.Int("retry", 3, "how often to retry faulty jobs") secretFile := flag.String("secret", "secret.txt", "file containing password.") socket := flag.String("socket", ".termite-socket", "socket to listen for commands") srcRoot := flag.String("sourcedir", "", "root of corresponding source directory") xattr := flag.Bool("xattr", true, "cache hashes in filesystem attribute.") flag.Parse() if *logfile != "" { f, err := os.OpenFile(*logfile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644) if err != nil { log.Fatal("Could not open log file.", err) } log.Println("Log output to", *logfile) log.SetOutput(f) } else { log.SetPrefix("M") } secret, err := ioutil.ReadFile(*secretFile) if err != nil { log.Fatal("ReadFile", err) } excludeList := strings.Split(*exclude, ",") root, sock := absSocket(*socket) opts := termite.MasterOptions{ Secret: secret, MaxJobs: *jobs, Excludes: excludeList, Coordinator: *coordinator, SourceRoot: *srcRoot, WritableRoot: root, Paranoia: *paranoia, Period: time.Duration(*houseHoldPeriod * float64(time.Second)), KeepAlive: time.Duration(*keepAlive * float64(time.Second)), FetchAll: *fetchAll, StoreOptions: cba.StoreOptions{ Dir: *cachedir, MemCount: *memcache, }, RetryCount: *retry, XAttrCache: *xattr, LogFile: *logfile, Socket: sock, } master := termite.NewMaster(&opts) log.Println(termite.Version()) go master.ServeHTTP(*port) master.Start() }