71 lines
1.7 KiB
Go
71 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"houston/appcontext"
|
|
"houston/cmd/app"
|
|
"houston/config"
|
|
"houston/internal/clients"
|
|
"houston/internal/metrics"
|
|
"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()
|
|
prometheus.MustRegister(
|
|
metrics.SlackChannelCreationFailureCounter,
|
|
metrics.RCAGenerationFailureCounter,
|
|
metrics.KrakatoaWorkflowFailureCounter,
|
|
metrics.ConferenceFailureCounter,
|
|
metrics.ZendutyCreationFailureCounter,
|
|
metrics.IncidentCreationFailureCounter,
|
|
metrics.IncidentResolutionFailureCounter,
|
|
)
|
|
|
|
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.GetLogger(), time.RFC3339, true))
|
|
|
|
r.Use(ginzap.RecoveryWithZap(logger.GetLogger(), true))
|
|
|
|
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)
|
|
|
|
sv.Handler(houston)
|
|
sv.Start()
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
if err := command.Execute(); err != nil {
|
|
logger.Error("houston core command execution failed", zap.Error(err))
|
|
os.Exit(1)
|
|
}
|
|
}
|