application lifecycle event support

This commit is contained in:
Marcus Efraimsson
2018-10-26 13:57:31 +02:00
parent cfb061ddab
commit 9edaa3fa8c
5 changed files with 82 additions and 12 deletions

View File

@@ -15,13 +15,17 @@ import (
"github.com/grafana/grafana/pkg/api"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/lifecycle"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/registry"
"golang.org/x/sync/errgroup"
"github.com/grafana/grafana/pkg/api"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/login"
"github.com/grafana/grafana/pkg/services/cache"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/social"
// self registering services
_ "github.com/grafana/grafana/pkg/extensions"
_ "github.com/grafana/grafana/pkg/metrics"
@@ -35,8 +39,7 @@ import (
_ "github.com/grafana/grafana/pkg/services/rendering"
_ "github.com/grafana/grafana/pkg/services/search"
_ "github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/social" // self registering services
"github.com/grafana/grafana/pkg/setting" // self registering services
_ "github.com/grafana/grafana/pkg/tracing"
"golang.org/x/sync/errgroup"
)
@@ -71,8 +74,7 @@ func (g *GrafanaServerImpl) Run() error {
g.loadConfiguration()
g.writePIDFile()
login.Init()
social.NewOAuthService()
lifecycle.Notify(lifecycle.ApplicationStarting)
serviceGraph := inject.Graph{}
serviceGraph.Provide(&inject.Object{Value: bus.GetBus()})
@@ -145,7 +147,7 @@ func (g *GrafanaServerImpl) Run() error {
}
sendSystemdNotification("READY=1")
lifecycle.Notify(lifecycle.ApplicationStarted)
return g.childRoutines.Wait()
}