// 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) }
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() }
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()) } }
// 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") }
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) }
func serve(addr string, handler http.Handler, wg *sync.WaitGroup, logger *logrus.Logger) { defer wg.Done() logger.Fatal(tablecloth.ListenAndServe(addr, handler)) }