package main import ( "log" "os" "os/signal" "syscall" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/logger" "github.com/gofiber/template/html/v2" _ "github.com/mattn/go-sqlite3" recov "github.com/gofiber/fiber/v2/middleware/recover" "zedshaw.games/webapp/api" "zedshaw.games/webapp/data" ) func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) engine := html.New("./views", ".html") app := fiber.New(fiber.Config{ Views: engine, ViewsLayout: "layouts/main", }) app.Use(logger.New()) app.Use(recov.New()) api.Setup(app) data.Setup("sqlite3", "db.sqlite3") app.Static("/", "./public") go func() { if err := app.Listen(":5001"); err != nil { log.Panic(err) } }() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) _ = <-c log.Println("Shutdown now...") _ = app.Shutdown() api.Shutdown() data.Shutdown() log.Println("Done.") }