package main

import (
	"flag"
	"fmt"
	"juwan-backend/app/email/mq/internal/config"
	"juwan-backend/app/email/mq/internal/consumer"

	"github.com/zeromicro/go-zero/core/conf"
	"github.com/zeromicro/go-zero/core/service"
)

var configFile = flag.String("f", "etc/email.yaml", "the config file")

func main() {
	flag.Parse()

	var c config.Config
	conf.MustLoad(*configFile, &c, conf.UseEnv())
	if err := c.SetUp(); err != nil {
		panic(err)
	}

	serviceGroup := service.NewServiceGroup()
	defer serviceGroup.Stop()

	for _, mq := range consumer.Mqs(c) {
		serviceGroup.Add(mq)
	}

	fmt.Print("Starting email service\n")
	serviceGroup.Start()
}
