func main() {
	if config.CLIConfig.WantsFunctionHelp {
		functions.PrintHelp(config.CLIConfig.FunctionHelpName)
		return
	}

	var err error

	configFile, err = config.NewConfigFile()

	if err != nil {
		log.Fatalf("Initialization error: %s", err)
	}

	errorChannel = make(chan error, 0)
	completionChannel = make(chan bool, 0)

	go run()

	for {
		select {
		case err := <-errorChannel:
			if e, ok := err.(*gotelemetry.Error); ok {
				logLevel := e.GetLogLevel()

				if logLevel >= config.CLIConfig.LogLevel {
					prefix := "Error"

					switch logLevel {
					case gotelemetry.LogLevelLog:
						prefix = "Info "

					case gotelemetry.LogLevelDebug:
						prefix = "Debug"
					}

					log.Printf("%s: %s", prefix, err)
				}

				continue
			}

			log.Printf("Error: %s", err.Error())

		case <-completionChannel:
			goto Done
		}
	}

Done:

	log.Println("No more jobs to run; exiting.\n")
}
Beispiel #2
0
func main() {
	var err error

	config.Init(VERSION, SOURCE_DATE)

	configFile, err = config.NewConfigFile()

	if err != nil {
		log.Fatalf("Initialization error: %s", err)
	}

	errorChannel = make(chan error, 0)
	completionChannel = make(chan bool, 1)

	wg := &sync.WaitGroup{}

	wg.Add(1)

	go handleErrors(errorChannel, wg)
	go run()

	for {
		select {
		case <-completionChannel:
			goto Done
		}
	}

Done:

	for len(errorChannel) > 0 {
	}

	close(errorChannel)
	wg.Wait()

	log.Println("No more jobs to run; exiting.")
}