datasource as cfg: basic implementation

This commit is contained in:
bergquist
2017-11-15 14:30:32 +01:00
parent 014f6d5a75
commit 39b6c04643
21 changed files with 9790 additions and 6 deletions
-6
View File
@@ -16,7 +16,6 @@ import (
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting"
_ "github.com/grafana/grafana/pkg/services/alerting/conditions"
@@ -88,11 +87,6 @@ func main() {
server.Start()
}
func initSql() {
sqlstore.NewEngine()
sqlstore.EnsureAdminUser()
}
func listenToSystemSignals(server models.GrafanaServer) {
signalChan := make(chan os.Signal, 1)
ignoreChan := make(chan os.Signal, 1)
+13
View File
@@ -21,7 +21,9 @@ import (
"github.com/grafana/grafana/pkg/services/cleanup"
"github.com/grafana/grafana/pkg/services/notifications"
"github.com/grafana/grafana/pkg/services/search"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting"
dsSettings "github.com/grafana/grafana/pkg/setting/datasources"
"github.com/grafana/grafana/pkg/social"
"github.com/grafana/grafana/pkg/tracing"
)
@@ -54,6 +56,12 @@ func (g *GrafanaServerImpl) Start() {
g.writePIDFile()
initSql()
err, _ := dsSettings.Init(filepath.Join(setting.HomePath, "conf/datasources.yaml"))
if err != nil {
g.log.Error("Failed to load datasources from config", "error", err)
g.Shutdown(1, "Startup failed")
return
}
metrics.Init(setting.Cfg)
search.Init()
login.Init()
@@ -87,6 +95,11 @@ func (g *GrafanaServerImpl) Start() {
g.startHttpServer()
}
func initSql() {
sqlstore.NewEngine()
sqlstore.EnsureAdminUser()
}
func (g *GrafanaServerImpl) initLogging() {
err := setting.NewConfigContext(&setting.CommandLineArgs{
Config: *configFile,