run

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 60 Imported by: 23

Documentation

Overview

Package run is the run (default) subcommand for the influxd command.

Index

Constants

View Source
const (
	// DefaultBindAddress is the default address for various RPC services.
	DefaultBindAddress = "127.0.0.1:8088"

	// EnvVarPrefix is the prefix used for environment variables that override
	// configuration values. For example, INFLUXDB_DATA_DIR overrides the
	// data.dir TOML setting.
	EnvVarPrefix = "INFLUXDB"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildInfo added in v0.9.4

type BuildInfo struct {
	Version string
	Commit  string
	Branch  string
	Time    string
}

BuildInfo represents the build details for the server code.

type Command

type Command struct {
	Version   string
	Branch    string
	Commit    string
	BuildTime string

	Closed chan struct{}

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	Logger *zap.Logger

	Server *Server

	// How to get environment variables. Normally set to os.Getenv, except for tests.
	Getenv func(string) string

	// How to list the full process environment. Normally set to os.Environ,
	// except for tests. Used by logEnvVarDiagnostics to detect env vars in the
	// configured namespace that were set but did not match any config field.
	Environ func() []string
	// contains filtered or unexported fields
}

Command represents the command executed by "influxd run".

func NewCommand

func NewCommand() *Command

NewCommand return a new instance of Command.

func (*Command) Close

func (cmd *Command) Close() error

Close shuts down the server.

func (*Command) LoadConfig added in v1.12.3

func (cmd *Command) LoadConfig(args ...string) (options Options, config *Config, appliedEnvVars []string, err error)

LoadConfig parses the command line flags, loads the config file, applies environment variable overrides, and validates the result. The returned appliedEnvVars slice lists the environment variable names that were applied during override processing; it is intended to be passed to logEnvVarDiagnostics once a logger has been configured.

func (*Command) ParseConfig

func (cmd *Command) ParseConfig(path string) (*Config, error)

ParseConfig parses the config at path. It returns a demo configuration if path is blank.

func (*Command) ParseFlags

func (cmd *Command) ParseFlags(args ...string) (Options, error)

ParseFlags parses the command line flags from args and returns an options set.

func (*Command) ReloadConfig added in v1.12.3

func (cmd *Command) ReloadConfig(args ...string)

ReloadConfig reloads the configuration and applies select configuration values to the running server.

func (*Command) Run

func (cmd *Command) Run(args ...string) error

Run parses the config from args and runs the server.

type Config

type Config struct {
	Meta           *meta.Config       `toml:"meta"`
	Data           tsdb.Config        `toml:"data"`
	Coordinator    coordinator.Config `toml:"coordinator"`
	FluxController control.Config     `toml:"flux-controller"`
	Retention      retention.Config   `toml:"retention"`
	Precreator     precreator.Config  `toml:"shard-precreation"`

	Monitor        monitor.Config    `toml:"monitor"`
	Subscriber     subscriber.Config `toml:"subscriber"`
	HTTPD          httpd.Config      `toml:"http"`
	Logging        logger.Config     `toml:"logging"`
	GraphiteInputs []graphite.Config `toml:"graphite"`
	CollectdInputs []collectd.Config `toml:"collectd"`
	OpenTSDBInputs []opentsdb.Config `toml:"opentsdb"`
	UDPInputs      []udp.Config      `toml:"udp"`

	ContinuousQuery continuous_querier.Config `toml:"continuous_queries"`

	// Server reporting
	ReportingDisabled bool `toml:"reporting-disabled"`

	// BindAddress is the address that all TCP services use (Raft, Snapshot, Cluster, etc.)
	BindAddress string `toml:"bind-address"`

	// TLS provides configuration options for all https endpoints.
	TLS tlsconfig.Config `toml:"tls"`

	// HardeningEnabled enables hardening options, such as restricting flux
	// HTTP requests to non-private (public) addresses. It is disabled by
	// default to preserve existing behavior. In the future this may gate
	// additional security features.
	HardeningEnabled bool `toml:"hardening-enabled"`
}

Config represents the configuration format for the influxd binary.

func NewConfig

func NewConfig() *Config

NewConfig returns an instance of Config with reasonable defaults.

func NewDemoConfig

func NewDemoConfig() (*Config, error)

NewDemoConfig returns the config that runs when no config is specified.

func (*Config) ApplyEnvOverrides added in v0.9.3

func (c *Config) ApplyEnvOverrides(getenv func(string) string) ([]string, error)

ApplyEnvOverrides apply the environment configuration on top of the config. Returns the names of environment variables that were applied (sorted and deduplicated) along with any error encountered.

func (*Config) Diagnostics added in v1.3.0

func (c *Config) Diagnostics() (*diagnostics.Diagnostics, error)

Diagnostics returns a diagnostics representation of Config.

func (*Config) FromToml added in v0.13.0

func (c *Config) FromToml(input string) error

FromToml loads the config from TOML.

func (*Config) FromTomlFile added in v0.13.0

func (c *Config) FromTomlFile(fpath string) error

FromTomlFile loads the config from a TOML file.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if the config is invalid.

type Options

type Options struct {
	ConfigPath string
	PIDFile    string
	CPUProfile string
	MemProfile string
}

Options represents the command line options that can be parsed.

func (*Options) GetConfigPath added in v0.13.0

func (opt *Options) GetConfigPath() string

GetConfigPath returns the config path from the options. It will return a path by searching in this order:

  1. The CLI option in ConfigPath
  2. The environment variable INFLUXDB_CONFIG_PATH
  3. The first influxdb.conf file on the path: - ~/.influxdb - /etc/influxdb

type PrintConfigCommand

type PrintConfigCommand struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

PrintConfigCommand represents the command executed by "influxd config".

func NewPrintConfigCommand

func NewPrintConfigCommand() *PrintConfigCommand

NewPrintConfigCommand return a new instance of PrintConfigCommand.

func (*PrintConfigCommand) Run

func (cmd *PrintConfigCommand) Run(args ...string) error

Run parses and prints the current config loaded.

type Server

type Server struct {
	BindAddress string
	Listener    net.Listener

	Logger    *zap.Logger
	MuxLogger *log.Logger

	MetaClient *meta.Client

	TSDBStore        *tsdb.Store
	QueryExecutor    *query.Executor
	PointsWriter     *coordinator.PointsWriter
	Subscriber       *subscriber.Service
	HttpdService     *httpd.Service
	OpenTSDBServices []*opentsdb.Service

	Services []Service

	Prometheus *prometheus.Registry

	// These references are required for the tcp muxer.
	SnapshotterService *snapshotter.Service

	Monitor *monitor.Monitor

	StartupProgressMetrics StartupProgress

	// Profiling
	CPUProfile            string
	CPUProfileWriteCloser io.WriteCloser
	MemProfile            string
	MemProfileWriteCloser io.WriteCloser
	// contains filtered or unexported fields
}

Server represents a container for the metadata and storage data and services. It is built using a Config and it manages the startup and shutdown of all services in the proper order.

func NewServer

func NewServer(c *Config, buildInfo *BuildInfo) (*Server, error)

NewServer returns a new instance of Server built from a config.

func (*Server) ApplyReloadedConfig added in v1.12.3

func (s *Server) ApplyReloadedConfig(config *Config, log *zap.Logger) error

func (*Server) Close

func (s *Server) Close() error

Close shuts down the meta and data stores and all services.

func (*Server) Err

func (s *Server) Err() <-chan error

Err returns an error channel that multiplexes all out of band errors received from all services.

func (*Server) LogQueriesOnTermination added in v1.9.6

func (s *Server) LogQueriesOnTermination() bool

func (*Server) Open

func (s *Server) Open() error

Open opens the meta and data store and all services.

func (*Server) SetLogOutput added in v0.13.0

func (s *Server) SetLogOutput(w io.Writer)

SetLogOutput sets the logger used for all messages. It must not be called after the Open method has been called.

func (*Server) SetStartupMetrics added in v1.12.0

func (s *Server) SetStartupMetrics(sp StartupProgress)

func (*Server) Statistics added in v1.0.0

func (s *Server) Statistics(tags map[string]string) []models.Statistic

Statistics returns statistics for the services running in the Server.

type Service

type Service interface {
	WithLogger(log *zap.Logger)
	Open() error
	Close() error
}

Service represents a service attached to the server.

type StartupProgress added in v1.12.0

type StartupProgress interface {
	AddShard()
	CompletedShard()
}

type StartupProgressLogger added in v1.12.0

type StartupProgressLogger struct {
	// contains filtered or unexported fields
}

func NewStartupProgressLogger added in v1.12.0

func NewStartupProgressLogger(logger *zap.Logger) *StartupProgressLogger

func (*StartupProgressLogger) AddShard added in v1.12.0

func (s *StartupProgressLogger) AddShard()

func (*StartupProgressLogger) CompletedShard added in v1.12.0

func (s *StartupProgressLogger) CompletedShard()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL