mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
co-authored by
Serge Zaitsev
parent
94dd17a936
commit
0de2c9eb96
@@ -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)
|
||||
}
|
||||
|
||||
@@ -93,14 +93,18 @@ func RunServer(opts ServerOptions) error {
|
||||
checkPrivileges()
|
||||
|
||||
configOptions := strings.Split(ConfigOverrides, " ")
|
||||
cfg, err := setting.NewCfgFromArgs(setting.CommandLineArgs{
|
||||
Config: ConfigFile,
|
||||
HomePath: HomePath,
|
||||
// tailing arguments have precedence over the options string
|
||||
Args: append(configOptions, opts.Context.Args().Slice()...),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := server.Initialize(
|
||||
setting.CommandLineArgs{
|
||||
Config: ConfigFile,
|
||||
HomePath: HomePath,
|
||||
// tailing arguments have precedence over the options string
|
||||
Args: append(configOptions, opts.Context.Args().Slice()...),
|
||||
},
|
||||
s, err := server.InitializeModuleServer(
|
||||
cfg,
|
||||
server.Options{
|
||||
PidFile: PidFile,
|
||||
Version: opts.Version,
|
||||
@@ -114,9 +118,7 @@ func RunServer(opts ServerOptions) error {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
go listenToSystemSignals(ctx, s)
|
||||
|
||||
return s.Run()
|
||||
}
|
||||
|
||||
@@ -130,7 +132,7 @@ func validPackaging(packaging string) string {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func listenToSystemSignals(ctx context.Context, s *server.Server) {
|
||||
func listenToSystemSignals(ctx context.Context, s *server.ModuleServer) {
|
||||
signalChan := make(chan os.Signal, 1)
|
||||
sighupChan := make(chan os.Signal, 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user