Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "metronome-api", Short: "Metronome api provide a rest api to manage metronome tasks", Long: `Metronome is a distributed and fault-tolerant event scheduler built with love by ovh teams and friends in Go. Complete documentation is available at http://ovh.github.io/metronome`, Run: func(cmd *cobra.Command, args []string) { log.Info("Metronome API starting") n := negroni.New() logger := &negroni.Logger{ ALogger: core.RequestLogger{ LogType: "access", Level: log.InfoLevel, }, } logger.SetDateFormat(negroni.LoggerDefaultDateFormat) logger.SetFormat(negroni.LoggerDefaultFormat) n.Use(logger) recovery := negroni.NewRecovery() recovery.Logger = core.RequestLogger{ LogType: "recovery", Level: log.ErrorLevel, } n.Use(recovery) n.Use(cors.New(cors.Options{ AllowedHeaders: []string{"Authorization", "Content-Type"}, AllowedMethods: []string{"GET", "POST", "DELETE"}, })) router := routers.InitRoutes() n.UseHandler(router) server := &http.Server{ Addr: viper.GetString("api.http.listen"), Handler: n, } metrics.Serve() go func() { log.Info("Metronome API started") log.Infof("Listen %s", viper.GetString("api.http.listen")) if err := server.ListenAndServe(); err != nil { log.WithError(err).Error("Could not start the server") } }() sigint := make(chan os.Signal, 1) signal.Notify(sigint, os.Interrupt) <-sigint if err := server.Close(); err != nil { log.WithError(err).Error("Could not stop gracefully the server") } database := pg.DB() if err := database.Close(); err != nil { log.WithError(err).Error("Could not stop gracefully close the connection to the database") } }, }
RootCmd launch the api agent.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.