Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RedisConnectRetries = 10
RedisConnectRetries indicates how many times the Redis connection should be retried
View Source
var RedisConnectRetryDelay = 1 * time.Second
RedisConnectRetryDelay indicates the time between Redis connection retries
View Source
var RootCmd = &cobra.Command{ Use: "ttn", Short: "The Things Network's backend servers", Long: `ttn launches The Things Network's backend servers`, PersistentPreRun: func(cmd *cobra.Command, args []string) { var logLevel = log.InfoLevel if viper.GetBool("debug") { logLevel = log.DebugLevel } var logHandlers []log.Handler if !viper.GetBool("no-cli-logs") { logHandlers = append(logHandlers, levelHandler.New(cliHandler.New(os.Stdout), logLevel)) } if logFileLocation := viper.GetString("log-file"); logFileLocation != "" { absLogFileLocation, err := filepath.Abs(logFileLocation) if err != nil { panic(err) } logFile, err = os.OpenFile(absLogFileLocation, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) if err != nil { panic(err) } if err == nil { logHandlers = append(logHandlers, levelHandler.New(jsonHandler.New(logFile), logLevel)) } } if esServer := viper.GetString("elasticsearch"); esServer != "" { esClient := elastic.New(esServer) esClient.HTTPClient = &http.Client{ Timeout: 5 * time.Second, } esUsername := viper.GetString("elasticsearch-username") esPassword := viper.GetString("elasticsearch-password") if esUsername != "" { esClient.SetAuthCredentials(esUsername, esPassword) } esPrefix := cmd.Name() if prefix := viper.GetString("elasticsearch-prefix"); prefix != "" { esPrefix = fmt.Sprintf("%s-%s", prefix, esPrefix) } logHandlers = append(logHandlers, levelHandler.New(esHandler.New(&esHandler.Config{ Client: esClient, Prefix: esPrefix, BufferSize: 10, }), logLevel)) } ctx = promlog.Wrap(apex.Wrap(&log.Logger{ Handler: multiHandler.New(logHandlers...), })) ttnlog.Set(ctx) grpclog.SetLogger(grpc.Wrap(ttnlog.Get())) if viper.GetBool("allow-insecure") { api.AllowInsecureFallback = true } ctx.WithFields(ttnlog.Fields{ "ComponentID": viper.GetString("id"), "Description": viper.GetString("description"), "Discovery Server Address": viper.GetString("discovery-address"), "Auth Servers": viper.GetStringMapString("auth-servers"), "Monitors": viper.GetStringMapString("monitor-servers"), }).Info("Initializing The Things Network") band.InitializeTables() }, PersistentPostRun: func(cmd *cobra.Command, args []string) { if logFile != nil { logFile.Close() } }, }
RootCmd is executed when ttn is executed without a subcommand
Functions ¶
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.