package main

import (
	"fmt"
	"github.com/beego/beego/v2/server/web"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis"
	"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
	"time"

	_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
	_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg"
	_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis"
	_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
	_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/port/beego"
)

func main() {
	defer func() {
		if r := recover(); r != nil {
			log.Logger.Error(fmt.Sprintf("%v", r))
		}
	}()

	log.InitLogHook(constant.ENABLE_KAFKA_LOG, true)
	redis.InitRedis()

	time.Sleep(time.Second)
	log.Logger.Info("server start!")
	web.Run()
	log.Logger.Info("server stop!")
}