Initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||
"github.com/pyroscope-io/pyroscope/pkg/agent/profiler"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/app"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/migrations"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/rest/routes"
|
||||
)
|
||||
|
||||
func main() {
|
||||
configFile := flag.String("config", "config.yml", "User Config file from user")
|
||||
migrate := flag.Bool("migrate", false, "Update db structure")
|
||||
flag.Parse()
|
||||
|
||||
// Cargar configuración
|
||||
app.Load(*configFile)
|
||||
|
||||
// Configurar Pyroscope profiler
|
||||
if app.Http.Profiler.Enabled {
|
||||
_, _ = profiler.Start(profiler.Config{
|
||||
ApplicationName: app.Http.Server.Name,
|
||||
ServerAddress: app.Http.Profiler.Server,
|
||||
})
|
||||
}
|
||||
|
||||
// Actualizar versión del servidor
|
||||
app.Http.Server.Version = app.Version
|
||||
|
||||
// Habilitar CORS
|
||||
app.Http.Server.App.Use(cors.New(cors.Config{
|
||||
AllowOrigins: "*",
|
||||
AllowMethods: "GET,POST,PUT,DELETE,OPTIONS",
|
||||
AllowHeaders: "Content-Type, Authorization",
|
||||
}))
|
||||
|
||||
if *migrate {
|
||||
// Ejecutar migraciones
|
||||
migrations.Migrate()
|
||||
} else {
|
||||
// Cargar rutas
|
||||
routes.LoadRoutes(app.Http.Server.App)
|
||||
app.Http.Route404()
|
||||
log.Fatal(app.Http.Server.ServeWithGraceFullShutdown())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user