[v10.0.x] Fix: Create store only once in cli mode (#70755)
Fix: Create store only once in cli mode (#70391)
fix: create store only once in cli mode
(cherry picked from commit 47b2e7f1d7)
Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
This commit is contained in:
co-authored by
Serge Zaitsev
parent
61afe6ed0f
commit
d90b80d993
@@ -6,16 +6,13 @@ import (
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands/datamigrations"
|
||||
"github.com/grafana/grafana/pkg/cmd/grafana-cli/commands/secretsmigrations"
|
||||
"github.com/grafana/grafana/pkg/cmd/grafana-cli/logger"
|
||||
"github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
||||
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/server"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/migrations"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
@@ -42,18 +39,7 @@ func runDbCommand(command func(commandLine utils.CommandLine, sqlStore db.DB) er
|
||||
return fmt.Errorf("%v: %w", "failed to initialize runner", err)
|
||||
}
|
||||
|
||||
tracer, err := tracing.ProvideService(runner.Cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v: %w", "failed to initialize tracer service", err)
|
||||
}
|
||||
|
||||
bus := bus.ProvideBus(tracer)
|
||||
|
||||
sqlStore, err := db.ProvideService(runner.Cfg, nil, &migrations.OSSMigrations{}, bus, tracer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v: %w", "failed to initialize SQL store", err)
|
||||
}
|
||||
|
||||
sqlStore := runner.SQLStore
|
||||
if err := command(cmd, sqlStore); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user