Files
houston-be/cmd/main.go

60 lines
1.4 KiB
Go
Raw Permalink Normal View History

package main
import (
"houston/appcontext"
"houston/cmd/app"
"houston/config"
"houston/internal/clients"
"houston/logger"
"os"
"time"
"github.com/spf13/viper"
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() {
config.LoadHoustonConfig()
godotenv.Load()
logger.InitLogger()
appcontext.InitiateContext()
appcontext.InitializeServices()
command := &cobra.Command{
Use: "houston",
2023-04-10 17:30:28 +05:30
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.GetLogger(), time.RFC3339, true))
r.Use(ginzap.RecoveryWithZap(logger.GetLogger(), true))
2023-05-18 14:44:30 +05:30
houston := r.Group("/houston")
httpClient := clients.NewHttpClient()
mjolnirClient := clients.NewMjolnirClient(
httpClient.HttpClient,
viper.GetString("mjolnir.service.url"),
viper.GetString("mjolnir.realm.id"),
)
sv := app.NewServer(r, appcontext.GetDB(), mjolnirClient)
2023-05-18 14:44:30 +05:30
sv.Handler(houston)
sv.Start()
return nil
},
}
if err := command.Execute(); err != nil {
2023-03-29 00:12:06 +05:30
logger.Error("houston core command execution failed", zap.Error(err))
os.Exit(1)
}
}