40 lines
910 B
Go
40 lines
910 B
Go
package main
|
|
|
|
import (
|
|
"alfred/cmd/collector/app"
|
|
"alfred/config"
|
|
"alfred/pkg/log"
|
|
"os"
|
|
"time"
|
|
|
|
ginzap "github.com/gin-contrib/zap"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/spf13/cobra"
|
|
_ "go.uber.org/automaxprocs"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func main() {
|
|
log.InitLogger("alfred-collector")
|
|
config.LoadCollectorConfig()
|
|
|
|
command := &cobra.Command{
|
|
Use: "alfred-collector",
|
|
Short: "alfred collector consumes events from kafka",
|
|
Long: "alfred collector receive all app events and ingest them into kafka",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
r := gin.New()
|
|
r.Use(ginzap.Ginzap(log.GetLogger(), time.RFC3339, true))
|
|
r.Use(ginzap.RecoveryWithZap(log.GetLogger(), true))
|
|
sv := app.NewServer(r)
|
|
sv.Start()
|
|
return nil
|
|
},
|
|
}
|
|
|
|
if err := command.Execute(); err != nil {
|
|
log.Error("alfred collector main command execution failed", zap.Error(err))
|
|
os.Exit(1)
|
|
}
|
|
}
|