Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "shar-telemetry", Short: "SHAR Telemetry Server", Long: ``, Run: func(cmd *cobra.Command, args []string) { cfg, err := config.GetEnvironment() if err != nil { panic(err) } if flags.Value.NatsConfig != "" { b, err := os.ReadFile(flags.Value.NatsConfig) if err != nil { slog.Error("read nats configuration file", slog.String("error", err.Error())) os.Exit(1) } storage.NatsConfig = string(b) } nc, err := nats.Connect(cfg.NatsURL) if err != nil { panic(err) } ctx := context.Background() js, err := jetstream.New(nc) if err != nil { panic(err) } if len(os.Args) > 1 && os.Args[1] == "--remove" { err1 := js.DeleteConsumer(ctx, "WORKFLOW_TELEMETRY", "Tracing") err2 := js.DeleteKeyValue(ctx, messages.KvTracking) if err1 != nil { panic(err1) } if err2 != nil { panic(err2) } return } mp, err := server.SetupMetrics(ctx, cfg, "shar-telemetry-processor") if err != nil { slog.Error("failed to init metrics", "err", err.Error()) } defer func() { err := mp.Shutdown(ctx) if err != nil { slog.Error("failed to shutdown metrics provider", "err", err.Error()) } }() exp, err := exporterFor(ctx, cfg) if err != nil { panic(err) } var lev slog.Level var addSource bool switch cfg.LogLevel { case "debug": lev = slog.LevelDebug addSource = true case "info": lev = slog.LevelInfo case "warn": lev = slog.LevelWarn default: lev = slog.LevelError } logx.SetDefault("shar", common.NewTextHandler(lev, addSource)) svr := server.New(ctx, nc, js, jetstream.FileStorage, exp) if err := svr.Listen(); err != nil { panic(err) } slog.Warn("STARTED TELEMETRY") sigChan := make(chan os.Signal, 3) signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT) <-sigChan }, PersistentPreRun: func(cmd *cobra.Command, args []string) { }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.