예제 #1
0
// Main is the top of the pile.  Start here.
func Main(log *logrus.Logger) {
	opts := NewOptions()
	if opts.Debug {
		log.Level = logrus.DebugLevel
	}

	if opts.FileStorePrefix == "" {
		opts.FileStorePrefix = "tmp"
	}

	server, err := NewServer(opts, log, nil)
	if err != nil {
		log.Fatal(err)
	}

	port := os.Getenv("PORT")
	if port == "" {
		port = "9839"
	}

	addr := fmt.Sprintf(":%s", port)
	log.WithFields(logrus.Fields{
		"addr": addr,
	}).Info("artifacts-service listening")

	server.Run(addr)
}
예제 #2
0
func runApplication(config *app.Config, logger *logrus.Logger) {
	application, err := app.NewApp(config, logger)
	if err != nil {
		logger.Fatal(err.Error())
	}

	logger.Infoln("starting the application...")
	application.Run()
}
예제 #3
0
func runMigrations(config *app.Config, logger *logrus.Logger) {
	logger.Infof("running migrations in '%s'...", config.DbFile)
	migrator, err := app.NewMigratable(config, logger)
	if err != nil {
		logger.Fatal(err.Error())
	}
	err = migrator.Migrate()
	if err != nil {
		logger.Fatal(err.Error())
	}
}
예제 #4
0
// MigratorMain is the entry point for the "migrate" cli command
func MigratorMain(log *logrus.Logger) {
	opts := NewOptions()
	if opts.Debug {
		log.Level = logrus.DebugLevel
	}

	log.Debug("spinning up database")

	db, err := metadata.NewDatabase(opts.DatabaseURL, log)
	if err != nil {
		log.Fatal(err)
	}

	log.Debug("migrating")

	err = db.Migrate(log)
	if err != nil {
		log.Fatal(err)
	}

	log.Info("database migration complete")
}
예제 #5
0
func main() {
	var logrusLogger *logrus.Logger = logrus.New()
	logrusLogger.Formatter = new(logrus.JSONFormatter)

	if len(os.Args) != 2 {
		logrus.Error("Must pass an arg to test program...")
		os.Exit(0)
	}

	switch os.Args[1] {
	case "logrus.Fatal":
		logrusLogger.Fatal("fatal error")
	case "logrus.Fatalf":
		logrusLogger.Fatalf("fatal error%s", "fatal error")
	case "bark.Fatal":
		bark.NewLoggerFromLogrus(logrusLogger).Fatal("fatal error")
	case "bark.Fatalf":
		bark.NewLoggerFromLogrus(logrusLogger).Fatalf("fatal error%s", "fatal error")
	}

	logrus.Error("Expected fatal methods to exit...")
	os.Exit(0)
}
예제 #6
0
func serve(addr string, handler http.Handler, wg *sync.WaitGroup, logger *logrus.Logger) {
	defer wg.Done()
	logger.Fatal(tablecloth.ListenAndServe(addr, handler))
}