Example #1
0
func coordinatorRun(config minion.MinionConfig, cmd *Command, args []string) {
	log.Printf("Bringing coordinator online\n")
	var err error

	if config.Templates != "" {
		Mailer, err = mailer.NewMailer(config.Templates)
		if err != nil {
			log.Fatal("%s\n", err)
		}
	}

	l, err := service.ListenFromKeys(
		fmt.Sprintf("%s:%d", config.Host, config.Port),
		config.Cert, config.Key, config.CaCert,
	)
	if err != nil {
		log.Fatalf("Server Ouchie! %s", err)
	}

	buildChannel := minion.BuildChannelMap{}
	clients := minion.OnlineClients{}
	coordinator := coordinatorService{
		BuildChannels: &buildChannel,
		Config:        &config,
		Clients:       &clients,
	}
	log.Printf("Great, waiting for Minions, and telling them what to do!\n")
	service.Handle(l, &coordinator)
}
Example #2
0
func main() {
	flags, err := config.LoadFlags("enqueued", &conf)
	if err != nil {
		log.Fatal(err)
	}
	flags.Parse(os.Args[1:])
	os.Chdir(conf.Root)

	if conf.Templates != "" {
		enqueuedMailer, err = mailer.NewMailer(conf.Templates)
		if err != nil {
			log.Fatal(err)
		}
	}

	files, err := ioutil.ReadDir(conf.Root)
	if err != nil {
		log.Fatal(err)
	}

	watcher, err := inotify.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}

	for _, file := range files {
		if err := Watch(watcher, file); err != nil {
			log.Fatal(err)
		}
	}

	for {
		select {
		case ev := <-watcher.Event:
			if ev.Mask^inotify.IN_CLOSE_WRITE != 0 ||
				!strings.HasSuffix(ev.Name, ".changes") {
				continue
			}
			Process(ev.Name)
		}
	}
}