Example #1
0
func main() {
	fs := flags.New().SetVersion(Version)
	fs.UseEnv = false
	fs.Boot()

	logx.SetLevel(log_level)
	prog, err := program.ParseFiles(flag.Args()...)
	logx.OnFatal(err)

	opts := options.NewGenOptions(layer, pack, core)

	gen_root := gen.NewGenRoot(prog, opts)

	// make package dir
	err = os.MkdirAll(filepath.Join(out, pack), os.ModePerm)
	logx.OnFatal(err)

	// Write types
	res, err := gen_root.Out()
	logx.OnFatal(err)
	for filename, box_res := range res {
		target := filepath.Join(out, pack, filename)
		err = ioutil.WriteFile(target, box_res, os.ModePerm)
		logx.OnFatal(err)
		logx.Infof("==> %s", target)
	}

	// Write Fns
	//	fn_fname, fn_res, err := gen_root.PipeOut()
	//	logx.OnFatal(err)
	//	target := filepath.Join(out, pack, fn_fname)
	//	err = ioutil.WriteFile(target, fn_res, os.ModePerm)
	//	logx.Infof("==> %s", target)
	//
	//	// Write package
	//	pack_res, err := gen_root.PackageOut()
	//	logx.OnFatal(err)
	//	target = filepath.Join(out, pack, pack) + ".go"
	//	err = ioutil.WriteFile(target, pack_res, os.ModePerm)
	//	logx.OnFatal(err)
	//	logx.Infof("==> %s", target)
}
Example #2
0
func main() {
	flags.New().
		SetVersion(Version).
		SetPrefix("CAP").
		SetHelp("Usage: {{.Name}} [OPTIONS] CAPFILE [CAPFILE ...]\n").
		Boot()
	log.SetOutput(os.Stderr)
	log.SetFormatter(&log.TextFormatter{
		ForceColors:      true,
		DisableTimestamp: true,
	})
	p, err := process.New(flag.Args())
	if err != nil {
		log.Error(err)
		flag.Usage()
	}
	p.Describe()
	p.Run()
	log.Info("All done")
}
Example #3
0
func main() {
	flags.New().SetPrefix("WAVES").Boot()
	logx.SetLevel(log_level)

	ctx, cancel := context.WithCancel(context.Background())

	mach := machine.NewMachine(ctx, interval)
	go mach.Start()

	datapointReporter := datapoint.NewReporter(&datapointOptions, noop)

	u, err := url.Parse(annotationsEndpoint)
	logx.OnFatal(err)
	if token != "" {
		u.User = url.User(token)
	}
	annReporter := annotation.NewReporter(&annotation.ReporterOptions{u}, noop)

	dp := dockerprobe.NewDockerProbe(dockerEndpoint,
		makeDockerReporter(datapointReporter),
		report.NewMetaReporter(strings.Split(dockerAnnotationTags, ","),
			annReporter),
	)
	err = mach.Add(dp)
	logx.OnFatal(err)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)
	<-sigChan
	logx.Info("bye")
	cancel()
}