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
co-authored by Serge Zaitsev
parent 94dd17a936
commit 0de2c9eb96
12 changed files with 321 additions and 50 deletions
+23
View File
@@ -1,10 +1,12 @@
//go:build wireinject && oss
// +build wireinject,oss
// This file should contain wiresets which contain OSS-specific implementations.
package server
import (
"github.com/google/wire"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/registry/backgroundsvcs"
@@ -20,6 +22,8 @@ import (
"github.com/grafana/grafana/pkg/services/datasources/guardian"
"github.com/grafana/grafana/pkg/services/encryption"
encryptionprovider "github.com/grafana/grafana/pkg/services/encryption/provider"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/hooks"
"github.com/grafana/grafana/pkg/services/kmsproviders"
"github.com/grafana/grafana/pkg/services/kmsproviders/osskmsproviders"
"github.com/grafana/grafana/pkg/services/ldap"
@@ -103,3 +107,22 @@ var wireExtsTestSet = wire.NewSet(
wireTestSet,
wireExtsBasicSet,
)
// The wireExtsBaseCLISet is a simplified set of dependencies for the OSS CLI,
// suitable for running background services and targeted dskit modules without
// starting up the full Grafana server.
var wireExtsBaseCLISet = wire.NewSet(
NewModuleRunner,
featuremgmt.ProvideManagerService,
featuremgmt.ProvideToggles,
hooks.ProvideService,
setting.ProvideProvider, wire.Bind(new(setting.Provider), new(*setting.OSSImpl)),
licensing.ProvideService, wire.Bind(new(licensing.Licensing), new(*licensing.OSSLicensingService)),
)
// wireModuleServerSet is a wire set for the ModuleServer.
var wireExtsModuleServerSet = wire.NewSet(
NewModule,
wireExtsBaseCLISet,
)