feat: add ability to launch targeted dskit modules in the grafana server CLI command (#74188)

* feat: add ability to launch targeted dskit modules in the grafana server CLI command

This commit adds a ModuleServer and ModuleRunner suitable for launching dskit services and updates the server cli command to use this instead of the full Server. The default behavior is unchanged and will launch the full Grafana server. Individual services are targeted by setting target=comma,seperated,list in the config file.

* require dev mode to target dskit modules

* remove unused type

* replace setting.CommandLineArgs w/setting.Cfg; the caller can deal with calling setting.NewCfg

* Update pkg/server/module_server.go

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>

---------

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
This commit is contained in:
Kristin Laemmert
2023-09-01 08:09:54 -04:00
committed by GitHub
parent 94dd17a936
commit 0de2c9eb96
12 changed files with 321 additions and 50 deletions

View File

@ -50,12 +50,17 @@ func runDbCommand(command func(commandLine utils.CommandLine, sqlStore db.DB) er
func initializeRunner(cmd *utils.ContextCommandLine) (server.Runner, error) {
configOptions := strings.Split(cmd.String("configOverrides"), " ")
runner, err := server.InitializeForCLI(setting.CommandLineArgs{
cfg, err := setting.NewCfgFromArgs(setting.CommandLineArgs{
Config: cmd.ConfigFile(),
HomePath: cmd.HomePath(),
// tailing arguments have precedence over the options string
Args: append(configOptions, cmd.Args().Slice()...),
})
if err != nil {
return server.Runner{}, err
}
runner, err := server.InitializeForCLI(cfg)
if err != nil {
return server.Runner{}, fmt.Errorf("%v: %w", "failed to initialize runner", err)
}