mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
0de2c9eb96
* 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>
46 lines
953 B
Go
46 lines
953 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/dskit/services"
|
|
|
|
"github.com/grafana/grafana/pkg/api"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
type coreService struct {
|
|
*services.BasicService
|
|
cfg *setting.Cfg
|
|
opts Options
|
|
apiOpts api.ServerOptions
|
|
server *Server
|
|
}
|
|
|
|
func NewService(cfg *setting.Cfg, opts Options, apiOpts api.ServerOptions) (*coreService, error) {
|
|
s := &coreService{
|
|
opts: opts,
|
|
apiOpts: apiOpts,
|
|
cfg: cfg,
|
|
}
|
|
s.BasicService = services.NewBasicService(s.start, s.running, s.stop)
|
|
return s, nil
|
|
}
|
|
|
|
func (s *coreService) start(_ context.Context) error {
|
|
serv, err := Initialize(s.cfg, s.opts, s.apiOpts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
s.server = serv
|
|
return s.server.Init()
|
|
}
|
|
|
|
func (s *coreService) running(_ context.Context) error {
|
|
return s.server.Run()
|
|
}
|
|
|
|
func (s *coreService) stop(failureReason error) error {
|
|
return s.server.Shutdown(context.Background(), failureReason.Error())
|
|
}
|