package main

import (
	"context"
	"os"
	"os/signal"
	"syscall"

	"go.uber.org/zap"

	"productier/apps/backend/internal/app"
)

func main() {
	logger, err := zap.NewProduction()
	if err != nil {
		panic(err)
	}
	defer logger.Sync()

	server, err := app.New(logger)
	if err != nil {
		logger.Fatal("create api app", zap.Error(err))
	}

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

	if err := server.RunContext(ctx); err != nil {
		logger.Fatal("run api server", zap.Error(err))
	}
}
