Exemple #1
0
func main() {
	log.SetLevel(log.InfoLevel)
	bin, version := extractFromTag(os.Getenv("TRAVIS_TAG"))
	pkg := packageName(bin)

	run("rm", "-rf", "dist/*")

	if bin == "" {
		log.Info("could not extract info from TRAVIS_TAG: skipping artifact packaging")
		os.Exit(0)
	}

	for _, cfg := range builds {
		name := fmt.Sprintf("%s-%s-%s-%s", bin, version, cfg.OS, cfg.Arch)
		dest := filepath.Join("dist", name)

		// make destination directories
		run("mkdir", "-p", dest)
		run("cp", "LICENSE-APACHE.txt", dest)
		run("cp", "COPYING", dest)
		run("cp", filepath.Join(pkg, "README.md"), dest)
		run("cp", filepath.Join(pkg, "CHANGELOG.md"), dest)

		// rebuild the binary with the version variable set
		build(
			fmt.Sprintf("github.com/stellar/go/%s", pkg),
			filepath.Join(dest, bin),
			version,
			cfg.OS,
			cfg.Arch,
		)

		packageArchive(dest, cfg.OS)
	}
}
Exemple #2
0
func run(cmd *cobra.Command, args []string) {
	var (
		cfg     Config
		cfgPath = cmd.PersistentFlags().Lookup("conf").Value.String()
	)
	log.SetLevel(log.InfoLevel)
	err := config.Read(cfgPath, &cfg)

	if err != nil {
		switch cause := errors.Cause(err).(type) {
		case *config.InvalidConfigError:
			log.Error("config file: ", cause)
		default:
			log.Error(err)
		}
		os.Exit(1)
	}

	driver, err := initDriver(cfg)
	if err != nil {
		log.Error(err)
		os.Exit(1)
	}

	mux := initMux(driver)
	addr := fmt.Sprintf("0.0.0.0:%d", cfg.Port)

	http.Run(http.Config{
		ListenAddr: addr,
		Handler:    mux,
		OnStarting: func() {
			log.Infof("starting federation server - %s", app.Version())
			log.Infof("listening on %s", addr)
		},
	})
}