The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/server/service.go

45 lines
953 B

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())
}