A website for my game dev stuff that supports chat, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
zedshaw-games/main.go

60 lines
1.2 KiB

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"
"zedshaw.games/webapp/config"
)
func main() {
config.Load("config.toml")
log.Printf("ADMIN is %s", config.Settings.Admin)
log.SetFlags(log.LstdFlags | log.Lshortfile)
engine := html.New(config.Settings.Views, ".html")
app := fiber.New(fiber.Config{
Views: engine,
ViewsLayout: config.Settings.Layouts,
CaseSensitive: true,
StrictRouting: true,
})
app.Use(logger.New())
app.Use(recov.New())
api.Setup(app)
data.Setup(config.Settings.Database.Driver, config.Settings.Database.Url)
// this sets up graceful shutdown
go func() {
if err := app.Listen(config.Settings.Port); 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.")
}