예제 #1
0
func main() {
	var opts Opts

	_, err := flags.Parse(&opts)
	if err != nil {
		os.Exit(1)
	}

	if logFp := common.InitLogging(opts.Debug, opts.LogFile); logFp != nil {
		defer logFp.Close()
	}

	log.Debug("hi there! (tickertape tickertape)")
	log.Infof("version: %s", version)

	cfgBytes, err := ioutil.ReadFile(opts.Config)
	common.CheckError("reading config file", err)

	var schedule []Schedule
	common.CheckError("parsing config file", yaml.Unmarshal(cfgBytes, &schedule))

	log.Errorf("%+v", schedule)

	common.ConfigureWorkers(opts.RedisHost, opts.RedisPort, opts.RedisDb)

	c := cron.New()

	for _, e := range schedule {
		// some weird scoping going on here
		func(entry Schedule) {
			c.AddFunc(entry.Spec, func() {
				jid, err := workers.Enqueue(entry.Queue, entry.Class, entry.Args)
				common.CheckError("scheduling something", err)

				log.WithField("something", entry.Spec).Infof("submitted job %s", jid)
			})
		}(e)
	}

	c.Start()

	select {}
}
예제 #2
0
func main() {
	var opts Options

	_, err := flags.Parse(&opts)
	if err != nil {
		os.Exit(1)
	}

	if logFp := common.InitLogging(opts.Debug, opts.LogFile); logFp != nil {
		defer logFp.Close()
	}

	log.Debug("hi there! (tickertape tickertape)")
	log.Infof("version: %s", version)

	common.ConfigureWorkers(opts.RedisHost, opts.RedisPort, opts.RedisDb)

	workers.Process(opts.Queue, shell.Shell, opts.Concurrency)

	workers.Run()
}