Files
houston-be/cmd/main.go
2023-04-10 17:30:28 +05:30

48 lines
1.1 KiB
Go

package main
import (
"github.com/spf13/viper"
"houston/cmd/app"
"houston/config"
"houston/pkg/postgres"
"os"
"time"
ginzap "github.com/gin-contrib/zap"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/spf13/cobra"
"go.uber.org/zap"
)
func main() {
logger, _ := zap.NewProduction()
config.LoadHoustonConfig(logger)
godotenv.Load()
command := &cobra.Command{
Use: "houston",
Short: "houston is replacement for blameless and incident management slackbot bot at Navi",
Long: "houston is replacement for blameless and incident management slackbot bot at Navi",
RunE: func(cmd *cobra.Command, args []string) error {
r := gin.New()
r.Use(ginzap.Ginzap(logger, time.RFC3339, true))
r.Use(ginzap.RecoveryWithZap(logger, true))
db := postgres.NewGormClient(viper.GetString("POSTGRES_DSN"), logger)
sv := app.NewServer(r, logger, db)
sv.Handler()
sv.Start()
return nil
},
}
if err := command.Execute(); err != nil {
logger.Error("houston core command execution failed", zap.Error(err))
os.Exit(1)
}
}