package main

import (
	"context"
	"go.uber.org/zap"
	"log"
	"os"
	"os/signal"
	"gitea.pena/SQuiz/core/internal/app"
	"gitea.pena/SQuiz/core/internal/initialize"
	"syscall"
)

var (
	commit    string = os.Getenv("COMMIT")
	buildTime string = os.Getenv("BUILD_TIME")
	version   string = os.Getenv("VERSION")
)

func main() {
	config, err := initialize.LoadConfig()
	if err != nil {
		log.Fatal("Failed to load config", zap.Error(err))
	}

	ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
	defer stop()

	if err = app.Run(ctx, *config, app.Build{
		Commit:  commit,
		Version: version,
	}); err != nil {
		log.Fatal("App exited with error", zap.Error(err))
	}
}
